相关疑难解决方法(0)

Python文件操作

我用这个python程序得到了一个错误的"IOError:[Errno 0] Error":

from sys import argv
file = open("test.txt", "a+")
print file.tell() # not at the EOF place, why?
print file.read() # 1
file.write("Some stuff will be written to this file.") # 2
# there r some errs when both 1 & 2
print file.tell()
file.close()
Run Code Online (Sandbox Code Playgroud)

什么似乎是问题?以下这两种情况都可以:

from sys import argv
file = open("test.txt", "a+")
print file.tell() # not at the EOF place, why?
# print file.read() # 1
file.write("Some stuff will be written to this file.") # 2 …
Run Code Online (Sandbox Code Playgroud)

python file-io

14
推荐指数
2
解决办法
1万
查看次数

IOError:[Errno 0] Python中的错误

我使用Windows 7.

myfile = open("matedata.txt", "a+")
print myfile.readline()
myfile.write("1")
myfile.close()
Run Code Online (Sandbox Code Playgroud)

这不起作用.

myfile.write("1")
IOError: [Errno 0] Error
Run Code Online (Sandbox Code Playgroud)

python io file-io

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

file-io ×2

python ×2

io ×1