[Tutor] File operation query

Joel Goldstick joel.goldstick at gmail.com
Thu Oct 15 12:32:02 EDT 2015


On Thu, Oct 15, 2015 at 12:00 PM, Reuben <reuben.dlink at gmail.com> wrote:

> Hi All,
>
> I need some clarification for below code. In line 2 of below code snippet,
> I have provided read and write permission. Assuming I have provided some
> string input as requested in line 1 - when I try to open "check.txt" file
> after running the script, it is always empty - it does not display the user
> input provided.
>
> May I know why?
>
> ######################################################################
>
> input1 = raw_input("Input1:")
>
>
> file = open("check.txt", "r+")
>
> file.write(input1 + "\n")
>
>
> for line in file:
>         print line
>
>
> print file.close()
> the above line should probably be:
>
    file.close()

Do you have a traceback?  Can you add that to your question?

> ######################################################################
>
>
> Regards,
> RD.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays


More information about the Tutor mailing list