在脚本中本意是调用python的内建函数open打开一个文件,结果调用了os.open,所以报错了,应该尽量避免使用from import
[crsusr@rws1270149 python_study]$ cat mypy02.py
#!/usr/bin/python3.7
#import sys,string,os
from os import *
f = open('ee.txt','w')
#print(dir(os))
[crsusr@rws1270149 python_study]$ ./mypy02.py
Traceback (most recent call last):
File "./mypy02.py", line 5, in <module>
f = open('ee.txt','w')
TypeError: an integer is required (got type str)
python open函数名字冲突
最新推荐文章于 2021-08-30 21:29:25 发布