33问答网
所有问题
python语言字典里还有列表列表是value值,遍历出列表怎么写代码
如题所述
举报该问题
推荐答案 推荐于2017-12-16
不知道你是不是这个意思,
字典调用values()方法会返回Value值所构成的列表,通过两个循环就能遍历字典里的列表
data = {'a':[1,2,3],'b':[4,5,6]}
for l in data.values():
for item in l:
print item
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://33.wendadaohang.com/zd/BP5BhB4P5dWR4c0cdc.html
相似回答
新手小白:
python
3中如何
遍历列表中
的
字典
的
value
并存放到一个变量中...
答:
values_list = [for
value
in _dict.values() for _dict in _list]
python中怎么
用两个
列表
组合成
字典,
相同key的vlue值组成列表
答:
lista=['a','b','c','a','b','c','d']listb=['1','2','3','4','5','6','7']dict={}for i,j in zip(lista,listb): if i not in dict.keys(): dict[i]=j else: dict[i]=[dict[i]] dict[...
python里
一个
字典列表,
如何判断一个
value
在不在这个
列表里
答:
参考
代码
#!/usr/bin/env
python
# -*- coding: utf-8 -*-#python 2.7dt = {"Tom":12,"Jack":10,"Lucy":15}#获得指定的key的
value
#方法一print "Jack age:%s"%dt["Jack"]#方法二:print "Tom age:%s"%dt.get("Tom")print "---"#遍历输出所有的值for name,age in dt.item...
大家正在搜
python循环遍历列表
python字典遍历
Python遍历列表
pythonfor循环遍历字符串
python enumerate
python list 遍历
python如何遍历字符串
python dict遍历
python中value
相关问题
python里一个字典列表,如何判断一个value在不在这个...
python列表里面有字典,该怎么读取字典中的value
python如何无限遍历字典中的value,在不知道字典里面...
python列表里面有字典,该怎么读取字典中的value
如何取出列表中字典的值并进行比对?python
Python 字典的value每一个都是两个元素的列表,如何...
python 如何将列表转为字典,key值相同则合并valu...
新手小白:python3中如何遍历列表中的字典的value并...