Python 处理异常 Python assert 语句 Python 打开文件open方法 Python 处理异常 #!/usr/bin/python try: fh = open("testfile", "w") 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" fh.close() Python assert 语句 Python 打开文件open方法