July 22nd, 2013, 09:22 AM
Join Date: Jul 2013
Time spent in forums: 1 Day 23 h 44 m 29 sec
Reputation Power: 1
Originally Posted by ofey
I am completely new to Python.
I wish to print
to a file. But with it also in a loop so that the image number will increase by one each time. So something like,
for x in range (1,100):
I can't even get this bit to work, so the next stage of writing this to file will be the next step.
Do I then need to have a file already created or by writing to a file will it be created?
Any help would be greatly appreciated,
The backslashes are creating escape characters. You'll need to either create raw strings with an r before the strings: r"string". Or double up the backslashes.
as for saving to a file, there are many different ways. The simple way is:
x = open('textfile.txt', 'w') #first argument is any filename and second is the file mode. w = write.
x.write('write stuff here')
x.close() #or x.flush() if you want to send it to file but keep writing.