当前位置: 首页 > news >正文

驻马店app和网站开发公司做网站卖菜刀需要什么手续

驻马店app和网站开发公司,做网站卖菜刀需要什么手续,举一个网络营销的例子,0735郴州招聘信息网计数器counter是包含在collections模块中的容器。 什么是容器Container#xff1f; 容器是容纳对象的对象。它们提供了一种访问所包含对象并对其进行迭代的方法。内置容器的例子有元组、列表和字典。其他内容包含在“collections”模块中。 Counter是dict的子类。因此#…计数器counter是包含在collections模块中的容器。 什么是容器Container 容器是容纳对象的对象。它们提供了一种访问所包含对象并对其进行迭代的方法。内置容器的例子有元组、列表和字典。其他内容包含在“collections”模块中。 Counter是dict的子类。因此它是一个无序的集合其中元素和它们各自的计数被存储为字典。这相当于一个包或多个其他语言集。 语法 class collections.Counter([iterable-or-mapping])初始化 计数器的构造函数可以通过以下任一方式调用 包含一系列项目使用包含键和计数的字典带有将字符串名称映射到计数的关键字参数 初始化计数器 # A Python program to show different ways to create # Counter from collections import Counter# With sequence of items print(Counter([B,B,A,B,C,A,B,B,A,C]))# with dictionary print(Counter({A:3, B:5, C:2}))# with keyword arguments print(Counter(A3, B5, C2))输出 Counter({B: 5, A: 3, C: 2}) Counter({B: 5, A: 3, C: 2}) Counter({B: 5, A: 3, C: 2})计数器更新 我们也可以通过以下方式创建一个空计数器 coun collections.Counter()并且可以通过update() 方法进行更新。相同的语法 coun.update(Data)# A Python program to demonstrate update() from collections import Counter coun Counter()coun.update([1, 2, 3, 1, 2, 1, 1, 2]) print(coun)coun.update([1, 2, 4]) print(coun)输出 Counter({1: 4, 2: 3, 3: 1}) Counter({1: 5, 2: 4, 3: 1, 4: 1}数据可以用初始化中提到的三种方式中的任何一种提供计数器的数据将增加而不是替换。计数也可以为零或负数。 # Python program to demonstrate that counts in # Counter can be 0 and negative from collections import Counterc1 Counter(A4, B3, C10) c2 Counter(A10, B3, C4)c1.subtract(c2) print(c1)输出 Counter({c: 6, B: 0, A: -6})列表中的唯一计数 我们可以使用Counter来计算列表或其他集合中的不同元素。 # An example program where different list items are # counted using counter from collections import Counter# Create a list z [blue, red, blue, yellow, blue, red]# Count distinct elements and print Counter aobject print(Counter(z))输出 Counter({blue: 3, red: 2, yellow: 1})打印计数器值 我们还可以使用keys() 、values() 和items() 方法访问计数器的所有键和值。这些方法分别返回计数器中的键、值和键值对的视图。 from collections import Counter my_counter Counter(abracadabra) print(my_counter.keys()) print(my_counter.values()) print(my_counter.items())输出 dict_keys([a, b, r, c, d]) dict_values([5, 2, 2, 1, 1]) dict_items([(a, 5), (b, 2), (r, 2), (c, 1), (d, 1)])访问计数器 一旦初始化计数器就像字典一样被访问。此外它不会引发KeyValue错误如果key不存在而是值的计数显示为0。 # Python program to demonstrate accessing of # Counter elements from collections import Counter# Create a list z [blue, red, blue, yellow, blue, red] col_count Counter(z) print(col_count)col [blue,red,yellow,green]# Here green is not in col_count # so count of green will be zero for color in col:print (color, col_count[color]) 输出 Counter({blue: 3, red: 2, yellow: 1}) blue 3 red 2 yellow 1 green 0elements() elements() 方法返回一个迭代器该迭代器生成Counter已知的所有项。 注意不包括count 0的元素。 # Python example to demonstrate elements() on # Counter (gives back list) from collections import Countercoun Counter(a1, b2, c3) print(coun)print(list(coun.elements()))输出 Counter({c: 3, b: 2, a: 1}) [a, b, b, c, c, c]most_common() most_common() 用于产生N个最频繁遇到的输入值及其相应计数的序列。 # Python example to demonstrate most_elements() on # Counter from collections import Countercoun Counter(a1, b2, c3, d120, e1, f219)# This prints 3 most frequent characters for letter, count in coun.most_common(3):print(%s: %d % (letter, count)) 输出 f: 219 d: 120 c: 3
http://www.zqtcl.cn/news/738954/

相关文章:

  • 建站自学网页转向功能网站
  • 网站都有什么费用做酒店网站有哪些目录
  • 本地郑州网站建设东莞网站优化中易
  • 动态域名可以建网站德州公司做网站
  • 深圳建设银行官方网站wordpress 添加qq
  • 甘肃第九建设集团公司网站网站对企业的好处
  • 论坛网站建设规划书公司网站建设与设计制作
  • 做棋牌游戏网站犯法吗如何进行搜索引擎的优化
  • 常见的网站首页布局有哪几种陈光锋网站运营推广新动向
  • 手机网站活动策划方案开一个设计公司
  • 宝塔建设网站教程visual studio 2010 网站开发教程
  • 做网站购买服务器做谷歌网站使用什么统计代码吗
  • 网站系统与网站源码的关系emlog轻松转wordpress
  • 网站的简介怎么在后台炒做吉林省住房城乡建设厅网站首页
  • 泉州易尔通网站建设国际酒店网站建设不好
  • 网页下载网站福田企业网站推广公司
  • 北京网站建设开发公司哪家好网站添加在线留言
  • 新建的网站怎么做seo优化平面广告创意设计
  • yy陪玩网站怎么做软件项目管理计划
  • 西安建网站价格低百度推广区域代理
  • 中英网站模板 照明公司注册在自贸区的利弊
  • 全球十大网站排名wordpress标题连接符
  • 网站开发可能遇到的问题四川建筑人才招聘网
  • 镇江网站托管怎么做淘宝网站赚钱吗
  • 交互式网站是什么知名vi设计企业
  • 上海个人做网站网站建设销售好做嘛
  • 邵阳建设网站哪家好手机网站栏目结构图
  • 做动车哪个网站查网站环境配置
  • 那些网站可以做h5国内新闻最新消息今天简短
  • asp网站开发实例河南省建设招投标网站