【发布时间】:2010-10-13 20:39:13
【问题描述】:
在 Python 中,以下语句不起作用:
f = open("ftmp", "rw")
print >> f, "python"
我得到错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 9] Bad file descriptor
但是使用下面的代码它可以工作:
g = open("ftmp", "r+")
print >> g, "python"
看来我需要修改文件模式。文件打开模式的深层复杂性是什么?
【问题讨论】: