您的位置:首页 > 编程语言 > Python开发

python字典操作

2016-05-19 17:09 218 查看
import json
dic = {
'str': 'this is a string',
'list': [1, 2, 'a', 'b'],
'sub_dic': {
'sub_str': 'this is sub str',
'sub_list': [1, 2, 3]
},
'end': 'end'
}
a = json.dumps(dic)
print a


输出结果: {"sub_dic": {"sub_str": "this is sub str", "sub_list": [1, 2, 3]}, "end": "end", "list": [1, 2, "a", "b"], "str": "this is a string"}

keys = ['ne_id','attached','name','devid','dev_zone_name']
values  = ['ne_id','attached','name','devid','dev_zone_name']

dict(zip(self.keys, values))


将两列list组成一个dict
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: