[Tutor] write to a file

python python <python@inkedmn.net>
Fri, 16 Aug 2002 14:45:07 -0700


it goes something like this:

file = file('C:\filename.txt', 'w')
x = 'hello, sir'
file.write(x)

that will write the string x to the file filename.txt

best of luck,
brett

GT> Hello,
        
GT>         I'm trying write something to a file but I keep on getting this error:

GT> Traceback (most recent call last):
GT>   File "test.py", line 9, in ?
GT>     os.open("C:\blah.txt", 'w')
GT> TypeError: an integer is required

GT>         I don't see what an integer has to do with anything? Thanks in advance...


GT> Gus

GT> _______________________________________________
GT> Tutor maillist  -  Tutor@python.org
GT> http://mail.python.org/mailman/listinfo/tutor