1. 首页
  2. 数据库
  3. 其它
  4. python中Counter() join() items() index()函数的用法

python中Counter() join() items() index()函数的用法

上传者: 2020-12-23 05:40:05上传 PDF文件 30.52KB 热度 36次
Counter(), join(), items(), index()函数的用法 Counter(), join(), items(), index()函数的用法 Counter() (1)需要从Collections集合模块中引入集合类Counter。 from collections import Counter (2)Counter(a)以字典的形式打印出数组a中每个元素出现的次数。 a = [1,4,2,3,2,3,4,2] from collections import Counter print Counter(a) 运行结果: Counter({2: 3, 3: 2, 4:
下载地址
用户评论