如何count列表中字符出现的次数?可以将其生成一个字典.key是列表中的字符串,value是出现的次数 例如gen = [2, 3, 4, 5, 6, 7, 3, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10, 6, 7, 8, 9, 10, 11, 7, 8, 9, 10, 11, 12]gen_cnt = {b:gen.count(b) for b in set(gen)}print(gen_cnt){2: 1, 3: 2, 4: 3…