0
當我嘗試運行模塊在Python打開文件用下面的代碼:錯誤蟒蛇IO錯誤:沒有這樣的文件或目錄
from sys import argv
script,filename = argv
txt = open(filename)
print "Here's your file %r:" % (filename)
print txt.read()
print "Type the filename again:"
file_again = raw_input(">")
txt_again =open(file_again)
print txt_again.read()
使我有以下錯誤:
IOError: [Errno 2] No such file or directory: 'ex15_sample.txt'
你可以嘗試raw_input並在Python控制檯中單獨打開一部分,並檢查發生了什麼。 – Karthikeyan
感謝您的評論,我會嘗試。 – Seventang