Pthon 断言

try:
    n=input("请输入一个数字:")
    assert n.isdigit(),"只能输入数字"
    print("你输入的数字是:",n)
except Exception as ex:
    print("发现错误:",ex)

猜你喜欢

转载自www.cnblogs.com/huihui55/p/12503289.html