摘要:
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()) 阅读全文
摘要:
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... 阅读全文
摘要:
import collections import json tree=lambda:collections.defaultdict(tree) some_dict=tree() some_dict['colours']['favourite']='yellow' print(json.dumps(some_dict)) 阅读全文