2020-06-05
2020-06-06 本文已影响0人
价值投机168
1.序列排序:
list = [1,8,2,56,12,'17','39']
如果使用list.sort()会报错,因为有int和str数据,不允许排。
如果加上list.sort(key=int)这样可以排
也可以list.sort(key=str)这样排
2.字典推导:

3.统计:字符数

统计中文的也行:
ct = collections.Counter('你好你好好好好')
1.序列排序:
list = [1,8,2,56,12,'17','39']
如果使用list.sort()会报错,因为有int和str数据,不允许排。
如果加上list.sort(key=int)这样可以排
也可以list.sort(key=str)这样排
2.字典推导:
3.统计:字符数
统计中文的也行:
ct = collections.Counter('你好你好好好好')