Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/313.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.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_Dictionary - Fatal编程技术网

Python 如何在字典列表中打印字典值?

Python 如何在字典列表中打印字典值?,python,list,dictionary,Python,List,Dictionary,我有一个字典列表,我想打印每个字典中的某些键: dict_results=[{'terms':['hi','bye'],'title':'01234def','text':'hello, how are you?'},{'terms':...}...] 这不起作用: for item in dict_results: print "{0},{1}".format(item[0]['title'],item[0]['text']) 键错误:0在列表中循环,然后访问每个字典的键: >

我有一个字典列表,我想打印每个字典中的某些键:

dict_results=[{'terms':['hi','bye'],'title':'01234def','text':'hello, how are you?'},{'terms':...}...]
这不起作用:

for item in dict_results:
    print "{0},{1}".format(item[0]['title'],item[0]['text'])

键错误:0在
列表中循环,然后访问每个字典的键:

>>> dict_results=[{'terms':['hi','bye'],'title':'01234def','text':'hello, how are you?'},
...               {'terms':0, 'title':'hello', 'text':'world'}]
>>> for d in dict_results:
...     print(d['title'], d['text'])
...
01234def hello, how are you?
hello world

循环浏览
列表
,然后访问每个字典的键:

>>> dict_results=[{'terms':['hi','bye'],'title':'01234def','text':'hello, how are you?'},
...               {'terms':0, 'title':'hello', 'text':'world'}]
>>> for d in dict_results:
...     print(d['title'], d['text'])
...
01234def hello, how are you?
hello world

循环浏览
列表
,然后访问每个字典的键:

>>> dict_results=[{'terms':['hi','bye'],'title':'01234def','text':'hello, how are you?'},
...               {'terms':0, 'title':'hello', 'text':'world'}]
>>> for d in dict_results:
...     print(d['title'], d['text'])
...
01234def hello, how are you?
hello world

循环浏览
列表
,然后访问每个字典的键:

>>> dict_results=[{'terms':['hi','bye'],'title':'01234def','text':'hello, how are you?'},
...               {'terms':0, 'title':'hello', 'text':'world'}]
>>> for d in dict_results:
...     print(d['title'], d['text'])
...
01234def hello, how are you?
hello world

删除
[0]
不是数组。删除
[0]
不是数组。删除
[0]
不是数组。删除
[0]
不是数组。谢谢你的解决方案,但我必须使用另一个,因为它是我如何构造问题的。谢谢你的解决方案,但我必须使用另一个,因为它是我如何构造问题的。谢谢你的解决方案,但我必须使用另一个,因为它是我如何构造问题的。谢谢您的解决方案,但我必须使用另一个,因为这是我如何组织我的问题。