Python学习笔记之OrderedDict使用示例

论坛 期权论坛 脚本     
匿名技术用户   2020-12-27 03:20   560   0
from collections import OrderedDict

#,{'b','1'}, {'c','2'}
json_dict = OrderedDict({})
json_dict.update({'a':'0'})
json_dict.update({'b':'1'})
json_dict.update({'c':'2'})
print(json_dict)
index = 1 #json_dict.index('a')
print(index)
new_item = OrderedDict({'B':'11'})
json_dict.update(new_item)
print(json_dict)

输出结果:

OrderedDict([('a', '0'), ('b', '1'), ('c', '2')])
1
OrderedDict([('a', '0'), ('b', '1'), ('c', '2'), ('B', '11')])

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP