我只是一个初学者,严格遵循Zed的“学习python的难题”。 我被困在练习15中。他给出的例子不会运行。它使返回错误:No such file or directory.
学习python这个难题练习15
的脚本是:
from sys import argv
script, filename = argv
txt = open(filename)
print "\n Here is your file %r: " % script
print txt.read()
print "I'll also ask you to type it again."
new_file = raw_input(">>>")
new_txt = open(new_file)
print new_txt.read()
的问题与 “new_txt =打开(NEW_FILE)” 行开始。该文件不在我的目录中,因此无法运行。 请有人帮我指点正确的道路。谢谢。
什么是练习15?请尝试制作[mcve] – Sayse
您使用什么命令行来运行脚本?它需要一个参数来读取文件。另外,当脚本显示'>>>'时,你在控制台中键入了什么? – Antwane
*“文件不在我的目录中的任何位置”* - 您似乎已经知道它为什么不起作用,那么您究竟在这里问什么? – poke