1. #使用笨方法学Python遇到的第一个问题 —— 如何关闭打开的文件
  2. #这足以证明我的C都还给老师了_(:з」∠)_我都不好意思说我还学过C++还学过Android TuT
  1. from sys import argv 
  2.  
  3. script, filename = argv 
  4.  
  5. txt = open(filename) 
  6.  
  7. print "Here's your file %r:" % filename 
  8. print txt.read() 
  9.  
  10. print "I'll also ask you to type it again:" 
  11. file_again = raw_input("> "
  12.  
  13. txt_again = open(file_again) 
  14.  
  15. print txt_again.read() 
  16.  
  17. txt.close() #关闭打开的文件
  18. txt_again.close()