Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 期望字符串,但获取字符列表_Python_List - Fatal编程技术网

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. 非常感谢你!真不敢相信我竟然忘了那个功能!