python字典操作

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

posted on 2016-05-19 17:09  与非朋仔  阅读(122)  评论(0编辑  收藏  举报

导航