h0945466 发表于 2018-8-13 07:59:16

python中的异常示例

try:  
   f = open("hello.txt", "r")
  
   try:
  
          print f.read(5)
  
   except:
  
          print "读文件异常"
  
   finally:
  
          print "释放资源"
  
          f.close()
  
except IOError:
  
   print "文件不存在"
页: [1]
查看完整版本: python中的异常示例