how to write or create (when no exist) a file using python and Google AppEngine

Posted by zjm1126 on Stack Overflow See other posts from Stack Overflow or by zjm1126
Published on 2010-04-21T03:55:48Z Indexed on 2010/04/21 7:43 UTC
Read the original article Hit count: 181

Filed under:
|
|
|
|

this is my code:

f = open('text/a.log', 'wb')
f.write('hahaha')
f.close()

and it is not create a new file when not exist

how to do this ,

thanks

updated

class MyThread(threading.Thread):
    def run(self):
        f = open('a.log', 'w')
        f.write('hahaha')
        f.close()

error is :

Traceback (most recent call last):
  File "D:\Python25\lib\threading.py", line 486, in __bootstrap_inner
    self.run()
  File "D:\zjm_code\helloworld\views.py", line 15, in run
    f = open('a.log', 'w')
  File "d:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1188, in __init__
    raise IOError('invalid mode: %s' % mode)
IOError: invalid mode: w

© Stack Overflow or respective owner

Related posts about python

Related posts about create