我收到的错误是:
没有这样的文件或目录。
该文件位于我保存代码所在的目录中。
这是我的代码:
from sys import argv
script, filename=argv
txt=open(filename)
print(f"So the name of the file is {filename}.")
print(txt.read())
输出:on cmd
E:\python codes\ python file1.py test.txt
Traceback (most recent call last):
File"file1.py", line 4, in <modeule>
txt=open(filename)
FileNotFoundError:: [Erno 2]No such file or directory: 'test.txt'