- #使用笨方法学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()
转载于:https://blog.51cto.com/susan1992/1177708