标签:title python code class name 标准 red items col
们自己写的字典只能保存输入的键值对,但是不能保存他们输入的顺序,这时候可以借助Python的标准库collections里的orderedDict类
from collections import OrderedDict my_ordered_diction = OrderedDict() my_ordered_diction[‘wukong‘] = ‘C++‘ my_ordered_diction[‘bajie‘] = ‘Java‘ my_ordered_diction[‘shaseng‘] = ‘Qt‘ my_ordered_diction[‘tangsheng‘] = ‘python‘ for name,laugage in my_ordered_diction.items(): print(name.title() + ‘ favorite laugage is ‘ + laugage.title())
标准库(一):collections之orderedDict
标签:title python code class name 标准 red items col
原文地址:https://www.cnblogs.com/boost/p/13359952.html