【发布时间】:2019-12-11 23:09:48
【问题描述】:
我正在尝试将用户输入的值附加到字典中,但它显示错误:
AttributeError: 'str' 对象没有属性 'append'
谁能找出错误?
Dict = {} # an empty dictionary to be filled later
Dict["SomeKey"] = []
Dict["SomeKey"] = input ("Enter a value: ") # it works
Dict["SomeKey"].append(input("Enter another value: ")) # This part gives me error !!!
AttributeError: 'str' 对象没有属性 'append'
【问题讨论】:
-
这是给你的字符串...(
input返回一个字符串)
标签: python list dictionary input append