摘要: 习题1:题目:给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。 #encoding=utf-8 while True: try: num=int(raw_input("input a number not more than 5 digits:")) except: "Plese input again:" else... 阅读全文
posted @ 2018-01-24 22:08 夏晓旭 阅读(821) 评论(0) 推荐(0)
摘要: 抛出异常 #coding=utf-8 def exceptionTest(num): if num<0: print "if num<0" raise Exception("Invalid num") else: print num if num == 0: raise ZeroDivisionEr 阅读全文
posted @ 2018-01-24 21:56 夏晓旭 阅读(4518) 评论(0) 推荐(0)