您可能从os模块导入了星号:
>>> open("test.dat","w")<open file 'test.dat', mode 'w' at 0x1004b20c0>>>> from os import *>>> open("test.dat","w")Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: an integer is required因此您使用了错误的打开功能。(我想您可以简单地完成
from os importopen,但是可能性较小。)通常,应避免这种导入样式
global,在实际情况下应避免使用。



