• python 计数器Counter


     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     ('Ahmed','Silver',6),
     9     ('Ahmed','Red',7),
    10 )
    11 
    12 favs = Counter((name,colour) for name, colour,value in colours)
    13 unions=Counter(name for name, colour,value in colours)
    14 print(favs)
    15 print(unions)
  • 相关阅读:
    Vijos1986
    vijos1790
    洛谷1005
    洛谷3381
    bzoj4034
    bzoj1564
    bzoj2648
    洛谷3348
    jzoi4964
    codevs3990
  • 原文地址:https://www.cnblogs.com/mahailuo/p/10201616.html
Copyright © 2020-2023  润新知