1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
class (Exception): def __init__(self, num, num_type): self.num = num self.num_type = num_type
num1 = input("输入数字:") num2 = input("输入数字:")
try: if num1.isdigit() is False or num2.isdigit() is False: raise ArgsException(2, "int") except ArgsException as ret: print("需要%d个%s参数" % (ret.num, ret.num_type))
|
近期评论