Saving variable value to a file does not work!!!!
Husam
husalwan at sci.kun.nl
Sun Sep 30 12:04:33 EDT 2001
Hi friends,
Im a newbie and trying to save the value of variable 'counter' to a
file, but it does not work.
The code Im usig is:
for line in lines: # I'm reading from file: test2.txt.
One of it's lines contain: ID 5.
string.split(line)
if line[0:2]=='ID':
counter=int(line[3])
output=open('test2.txt','a') # Hier Im opening the same file for
append.
output.write(counter +1) # This is the trouble making
line!
output.close()
The error message I get when this code is run:
Traceback (innermost last):
File "./script.py", line 23, in ?
output.write(counter+1)
TypeError: read-only buffer, int
Thanks in advance,
More information about the Python-list
mailing list