# count = input("用户输入相加的数字(例如:5+1):") # li = count.split('+') #split是切割,默认按空格切割,我指定了+号切割 # uesrcount = int(li[0] )+ int (li[1]) #把列表元素按照索引转换成int类型,然后相加的和赋值给uesrcount # print(uesrcount) # 用户输入多个数字相加计算 # l1 = input("输入") # count = l1.split('+') #split是把用户输入的元素变成列表,以+号切割赋值给count # count1 = 0 # for i in count: # # count1 = count1 + int(i) # print(count1) counten = input("用户输入相加的数字") l1 = counten.split('+') restli = 0 for i in l1: restli = restli + int(i) print(restli) print(restli)