我只是一個初學者,嚴格遵循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