import sys
import time
import os poem='''\
测试读写文件
'''
print(os.getcwd())
f=file(os.getcwd()+'/python.txt','w')
f.write(poem)
f.close() C:\Users\Administrator\Desktop
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\pythonTwo.py", line , in <module>
f=file(os.getcwd()+'/python.txt','w')
NameError: name 'file' is not defined
[Finished in .2s with exit code ] 解决方法:file()改为open()
相关文章
- 04-12", line 1, in
NameError: name 'nan' is not defined">Python使用eval强制转换字符串为字典时报错:File " ", line 1, in NameError: name 'nan' is not defined - 04-12Python解决NameError: name 'reload' is not defined的问题
- 04-12python NameError: name 'file' is not defined
- 04-12python NameError: name 'raw_input' is not defined
- 04-12pycharm python @符号不能识别 NameError: name 'app' is not defined
- 04-12Python报错:name 'reload' is not defined
- 04-12", line 1, in
NameError: name 'f' is not defined">Python2 错误记录1File " ", line 1, in NameError: name 'f' is not defined - 04-12NameError: name 'pip' is not defined
- 04-12paip.python NameError name 'xxx' is not defined\
- 04-12NameError:name ‘xrange’ is not defined