Python 期望字符串,但获取字符列表
这个问题已经解决了。但我并没有很好地解释我的问题。所以我想在这里简化一下:Python 期望字符串,但获取字符列表,python,list,Python,List,这个问题已经解决了。但我并没有很好地解释我的问题。所以我想在这里简化一下: string1 = "vege" list1 = [] list1+=string1 # The output will be ["v","e","g","e"] # If you want to add the word to the list, instead, you should use .append() lis
string1 = "vege"
list1 = []
list1+=string1
# The output will be ["v","e","g","e"]
# If you want to add the word to the list, instead, you should use .append()
list1.append(string1)
当您尝试向列表中添加字符串时,它会尝试迭代字符串中的每个字符并将其附加到字符串中 如果您打算将一个类别添加到新的类别列表中,请使用append
不要使用
new_category+=key
,而是使用new_category.append(key)
代码不完整。很抱歉,我可以在这里简化一下:“'asdf=[]asdf+=”sean“asdf”“”它会给我一个[“s”,“e”,“a”,“n”],我希望得到一个[“sean”]在发布一个长的源代码片段之前,请先解释您试图实现的目标。two\u list\u函数的公共因子是什么?提供来源code@Pygirl. 非常感谢你!真不敢相信我竟然忘了那个功能!