- 论坛徽章:
- 3
|
本帖最后由 tomer 于 2014-11-02 21:01 编辑
- #cat file
- def doplus(arg1,arg2):
- if type(arg1)==type(1) and type(arg2)==type(1):
- return arg1+arg2
- else:
- raise TypeError("Paramete isnot correct!")
- return False
- print(doplus("a","r"))
- # python file
- Traceback (most recent call last):
- File "file", line 7, in <module>
- print(doplus("a","r"))
- File "file", line 5, in doplus
- raise TypeError("Paramete isnot correct!")
- TypeError: Paramete isnot correct!
复制代码
- 假如参数不是整型,我只想让输出为:
- TypeError: Paramete isnot correct!或
- Paramete isnot correct!
- 其它的错误不要显示,该怎么办?
复制代码 |
|