[Tutor] How to write strings with new line character in a file
Bob Gailer
bgailer at alum.rpi.edu
Fri Oct 13 05:35:08 CEST 2006
Asrarahmed Kadri wrote:
> Folks,
>
> I am trying to enter names in a file; each on a new line with this
> code, but not working:
>
> done = 0
> *while not done:
> str = raw_input("Enter login name:\t to quit type 'q': ")
> if str == 'q':
> done = 1
> else: *
> * str = str + '\n'*
> * fd.write(str)
> *
No can help without seeing the code that creates fd. Please post that.
> The traceback is as under:
>
> Traceback (most recent call last):
> File "scrap.py", line 38, in ?
> fd.write(str)
> IOError: (0, 'Error')
>
> Please help to rectify this error...
> --
> To HIM you shall return.
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
--
Bob Gailer
510-978-4454
More information about the Tutor
mailing list