Writing ASCII text files
Posted on 2004-08-19
I have a list, to which I have appended various strings, simply using myArray.append("hello") for example. Now I need to write a simple routine that works through the array and saves the contents line by line to a text file (ASCII format).
So.... if I appended "apple", "fish" and "pen" to my array, I'd like the text file to have:
Separated each time by a carriage return, so that when I open it in, say, notepad the entries are on successive lines. The other requirement is that Python creates the file - for some reason my script returns the error that the filename/path of the file does not exist, so I need some kind of command that creates the file in the first place.