Skip to main content
 首页 » 编程设计

python之打开文件 : Writing is invalid mode

2025年05月04日18insus

执行时:

path=os.path.dirname(__file__)+'/log.txt' 
log=open(path,"w",encoding='utf-8') 

我得到:

log=open(path,'w',encoding='utf-8') 
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1203, in __init__ 
raise IOError('invalid mode: %s' % mode) 
IOError: invalid mode: w 

我不确定为什么我不能写入文件?

请您参考如下方法:

App Engine's Python runtime supports Python 2.5 – newer versions of Python, including Python 2.6, are not currently supported. For security reasons, some Python modules written in C won't run in App Engine's sandbox. Because App Engine doesn't support writing to disk or opening direct network connections, other libraries that rely on this may not be fully usable.