1 fname = raw_input("enter filename:") 2 print 3 4 try: 5 fobj = open (fname, 'r') 6 except IOError ,e: 7 #except IOError ,e: 和上一行意思一样,猜测应该是as和,有一样的作用 8 print "*** file open error:", e 9 else: 10 for eachline in fobj: 11 print eachline 12 fname.close()