写python时,在文件部分,我想打开文件并输出,但会报错(FileNotFoundError: [Errno 2] No such file or directory: 'D:\pythoncode\heoqwe.txt')

而且该文件的确实在此目录下

写python时,在文件部分,我想打开文件并输出,但会报错(FileNotFoundError: [Errno 2] No such file or directory: 'D:\pythoncode\heoqwe.txt')


有可能你的文件名是“heoqwe.txt.txt”,隐藏后缀了哟
file = open('D:\\pythoncode\\heoqwe.txt.txt')