#-*-coding:utf-8-*- ''' 实现一个加法计数器 如5+7+9,进行分割再进行计算,将结果存入字典中dic = {"":"} ''' dic = {} content = input("请输入内容:").strip() content_list = content.split('+') #print(content_list) sum = 0 for i in content_list: sum = sum+int(i) # int会自动去掉空格 #print(sum) dic.setdefault("计算结果为:",sum) print(dic)