除数为0,程序异常的处理

import random while True: def exp_exception(x,y): try: a=int(x/y) print(“a=”, a) return a except Exception: print(“程序出现异常,异常信息:被除数为0”) cs_input=int(input(“请输入被除数”)) exp_exception(random.randint(10000)
相关文章
相关标签/搜索