- #使用笨方法學Python遇到的第一個問題 —— 如何關閉打開的文件
- #這足以證明我的C都還給老師了_(:з」∠)_我都不好意思說我還學過C++還學過Android TuT
- from sys import argv
- script, filename = argv
- txt = open(filename)
- print "Here's your file %r:" % filename
- print txt.read()
- print "I'll also ask you to type it again:"
- file_again = raw_input("> ")
- txt_again = open(file_again)
- print txt_again.read()
- txt.close() #關閉打開的文件
- txt_again.close()