代码:
import sys
with open(sys.argv[1]) as f:
lines = f.readlines()
for line in lines[0:]:
columns = line.split()
print(columns[0])
输出:
Traceback (most recent call last):
File "scissors.py", line 2, in <module>
with open (sys.argv[1]) as f:
FileNotFoundError: [Errno 2] No such file or directory: '1'
(指向旧图片的链接:https://i.stack.imgur.com/aG1vr.png,https://i.stack.imgur.com/wSpLG.png)
答案 0 :(得分:0)
"your file.txt"
r
,使用原始字符串(以及复制的文件路径中的反斜杠):
r"C:\Folder\Subfolder\another_one\your_file.txt"