• python 列表元素统计出现的次数并输出字典


    import collections  
    my_list = [10,10,10,10,20,20,20,20,40,40,50,50,30]  
    print("Original List : ",my_list)  
    ctr = collections.Counter(my_list)  
    print("Frequency of the elements in the List : ",dict(ctr))
  • 相关阅读:
    20210304
    20210303
    20210302
    20210210
    20210209
    20210208
    20210207
    例4-6
    例4-5
    例4-4
  • 原文地址:https://www.cnblogs.com/sea-stream/p/9971306.html
Copyright © 2020-2023  润新知