摘要:
from collections import namedtuple Animal=namedtuple('Animal','name age type') perry=Animal(name='perry',age=1,type='cat') print(perry.type) print(perry[0]) print(perry._asdict())
阅读全文
posted @ 2018-12-31 11:25
hailuo
阅读(215)
推荐(0)
编辑
摘要:
1 from collections import Counter 2 colours=( 3 ('Yasoob','Yellow',1), 4 ('Ali','Blue',2), 5 ('Arham','Green',3), 6 ('Ali','Black',4), 7 ('Yasoob','Red',5), 8 ('A...
阅读全文
posted @ 2018-12-31 11:13
hailuo
阅读(346)
推荐(0)
编辑
摘要:
import collections import json tree=lambda:collections.defaultdict(tree) some_dict=tree() some_dict['colours']['favourite']='yellow' print(json.dumps(some_dict))
阅读全文
posted @ 2018-12-31 10:45
hailuo
阅读(2562)
推荐(0)
编辑