python学习exception
来源:互联网 发布:db2 查看数据库版本 编辑:程序博客网 时间:2024/05/20 10:11
#-*- encoding: utf-8 -*-'''Created on 2013-1-7@author: '''#程序在执行的过程中产生异常,但不希望程序终止执行,这时就需要#用try和except 语句对异常进行处理。filename = ""while 1: filename = raw_input("please input the filename") if(filename == ""): continue try: f=open(filename,"r") print ("open the filename %s" % filename) except: print ("this is no filename: %s\n" % filename) break #自定义异常信息#raise有两个参数,第一个是由我们自己定义的异常类型,第二个是关于#此异常的少量说明信息 def inputage(): num = raw_input("input your age") if(num<18 or num > 65): raise "BadNum", "age is illeage" return numprint inputage()
- python学习exception
- Python Exception
- Python Exception
- python exception
- Python Exception
- python exception
- python exception
- Python exception
- 《Beginning Python From Novice to Professional》学习笔记十:Exception
- python的异常Exception
- Python Exception Name
- python Exception 异常处理
- Python,异常 exception
- python re-raise exception
- Python中的try... exception
- python 获取exception 名字
- Python Built-in Exception
- Python 异常(Exception)
- 使用cvs的时候,WEB-INF/classes中不能编译生成class文件的原因?
- JAVA设计模式(20) —组合(Composite)模式
- Linux stty命令
- hdu 1069 Monkey and Banana(dp)
- SAP 工具、平台、关键字详细记载
- python学习exception
- CMAKEUP用法 2010-9-23 12:52
- CentOS配置Keepalived 做双机热备切换
- IIS7 url重写
- JQuery的使用方法汇总(2)——JQuery选择器(编辑中……)
- 60-思考题(2)-将1到9 这九个数字分成若干个数,满足一定的算式
- 802.1ad帧格式
- linux下configure参数简单说明
- (JAVA自学笔记)I/O流操作