func.py 360 Bytes Edit 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 def w(): total = [] while True: unit= input("请输入:") try: unit2 = int(unit) except: if unit== 'q': break else: total.append(unit2) return total def sum(list1): count =0 for i in list1: count = count + i return count print(sum(w()))