#OrderDict

python之collections模块(OrderDict,defaultdict)

前言:importcollectionsprint([namefornameindir(collections)ifnotname.startswith("_")])['AsyncIterable','AsyncIterator','Awaitable','ByteString','Callable','ChainMa...

python OrderDict

#encoding:utf-8importcsvimportcollectionsd={'banana':3,'apple':4,'pear':1,'orange':2}print(d)kd=collections.OrderedDict(sorted(d.items(),key=lambdat:t[0]))print...
代码星球 ·2020-09-13