Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.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,我想列一张这样的清单。请帮帮我。 谢谢 您可以使用列表理解从源列表中的每个词典中获取“地址”键: result = (15620, 10180, 10190, 20900, 8190, 43110, 24780, 50130) 您可以使用get() k将为您提供所需的输出 result = (15620, 10180, 10190, 20900, 8190, 43110, 24780, 50130) result = [ d['address'] for d in source ] k=[

我想列一张这样的清单。请帮帮我。 谢谢


您可以使用列表理解从源列表中的每个词典中获取“地址”键:

result = (15620, 10180, 10190, 20900, 8190, 43110, 24780, 50130)

您可以使用
get()

k将为您提供所需的输出

result = (15620, 10180, 10190, 20900, 8190, 43110, 24780, 50130)
result = [ d['address'] for d in source ]
k=[]
for i in source:
    k.append(i.get("address", ""))