Python 打开文件open方法 Python 处理异常 Python Try finally 语句 Python 打开文件open方法 #!/usr/bin/python try: fh = open("testfile", "r") fh.write("This is my test file for exception handling!!") except IOError: print "Error: can\'t find file or read data" else: print "Written content in the file successfully" Python 处理异常 Python Try finally 语句