IOError:[Errno 0] Python中的错误

时间:2013-11-09 19:07:16

标签: python file-io io

我使用的是Windows 7。

myfile = open("matedata.txt", "a+")
print myfile.readline()
myfile.write("1")
myfile.close()

这不起作用。

myfile.write("1")
IOError: [Errno 0] Error

1 个答案:

答案 0 :(得分:-2)

使用python打开文件时,需要指定所需的访问类型(读取,写入或追加):

  • a - 追加
  • r - 供阅读
  • w - 写作

'+'表示如果不存在则更新/创建新。

你得到IOError是因为你打开文件而你尝试用相同的FD(文件传感器)进行读写操作

相关问题