Commit b6ff4639 by BellCodeEditor

auto save

parent 18ad0ac0
Showing with 4 additions and 4 deletions
def new_input(): def new_input():#函数的定义,相当于把书放进书包里
total = [] total = []
while True: while True:
unit = input('请输入(q退出):') unit = input('请输入(q退出):')
if unit == 'q': if unit == 'q':
break break
else: else:
try: try:#提醒用户输入数字
unit = int(unit) unit = int(unit)
except: except:
print("请重新输入一个数字") print("请重新输入一个数字")
...@@ -13,4 +13,5 @@ def new_input(): ...@@ -13,4 +13,5 @@ def new_input():
total.append(unit) total.append(unit)
print("-"*30) print("-"*30)
print(total) print(total)
new_input()
\ No newline at end of file new_input() #函数的调用,相当于背起书包去上学
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment