import sysimport timeimport ospoem='''\测试读写文件'''print(os.getcwd())f=file(os.getcwd()+'/python.txt','w')f.write(poem)f.close()C:\Users\Administrator\DesktopTraceback (most recent call last): File "C:\Users\Administrator\Desktop\pythonTwo.py", line 9, inf=file(os.getcwd()+'/python.txt','w')NameError: name 'file' is not defined[Finished in 0.2s with exit code 1]解决方法:file()改为open()