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

合肥网站开发培训学校设计师网上接单被骗

合肥网站开发培训学校,设计师网上接单被骗,建设旅游网网站软件,h5做的网站有哪些在本教程中#xff0c;我们将编写一个程序#xff0c;该程序将列表中具有与第二个元素相同的元素的所有元组分组。让我们看一个例子来清楚地理解它。输入值[(Python, nhooos), (Management, other), (Django, nhooos), (React,nhooos), (Social, other), (Business, other)]输…在本教程中我们将编写一个程序该程序将列表中具有与第二个元素相同的元素的所有元组分组。让我们看一个例子来清楚地理解它。输入值[(Python, nhooos), (Management, other), (Django, nhooos), (React,nhooos), (Social, other), (Business, other)]输出结果{nhooo: [(Python, nhooos), (Django, nhooos), (React, nhooos)],other’: [(Management, other), (Social, other), (Business, other)]}我们必须从列表中对元组进行分组。让我们看看解决问题的步骤。用必需的元组初始化一个列表。创建一个空字典。遍历元组列表。检查元组的第二个元素在字典中是否已经存在。如果已经存在则将当前元组追加到其列表中。否则使用当前元组的列表来初始化键。最后您将获得具有所需修改的字典。示例# initializing the list with tuplestuples  [(Python, nhooos), (Management, other), (Django, tialspoints), (React, nhooos), (Social, other), (Business, other)]# empty dictresult  {}# iterating over the list of tuplesfor tup in tuples:# checking the tuple element in the dictif tup[1] in result:# add the current tuple to dictresult[tup[1]].append(tup)else:# initiate the key with listresult[tup[1]]  [tup]# priting the resultprint(result)输出结果如果运行上面的代码则将得到以下结果。{nhooos: [(Python, nhooos), (Django, nhooos(React, nhooos)], other: [(Management, other), (Social, other), (Business, other)]}我们使用defaultdict跳过上述程序中的if条件。让我们使用defaultdict解决它。示例# importing defaultdict from collectionsfrom collections import defaultdict# initializing the list with tuplestuples  [(Python, nhooos), (Management, other), (Django, tialspoints), (React, nhooos), (Social, other), (Business, other)]# empty dict with defaultdictresult  defaultdict(list)# iterating over the list of tuplesfor tup in tuples:result[tup[1]].append(tup)# priting the resultprint(dict(result))输出结果如果运行上面的代码则将得到以下结果。{nhooos: [(Python, nhooos), (Django, nhooos(React, nhooos)], other: [(Management, other), (Social, other), (Business, other)]}结论您可以按自己喜欢的方式解决不同的问题。我们在这里看到了两种方式。如果您对本教程有任何疑问请在评论部分中提及。
http://www.zqtcl.cn/news/798931/

相关文章:

  • 装修网站模板国家正规现货交易平台
  • 福州高端网站制作网站建设项目单子来源
  • 网站制作的行业广州网站推广方案
  • 网站主域名建设通怎么样
  • 网站是如何建立的广告设计与制作工作内容
  • 网站优化课程培训公司取名生成器免费
  • 如何设立网站做外国网站买域名
  • 惠州网站建设公司排名聊城专业网站设计公司
  • 网站建设龙岗电子商务有限公司官网
  • 分栏型网站服装设计网站模板
  • 建设网站备案与不备案区别企业网站怎么做排名
  • php mysql的网站开发html网站制作答辩ppt
  • 网站制作有名 乐云践新专家网页制作公司需要什么资质
  • 织梦怎么用框架实现在浏览器的地址栏只显示网站的域名而不显示出文件名电脑网站模板
  • 北京网络营销网站品牌营销增长公司哪家好
  • 网站反链有好处吗稷山网站建设
  • 廊坊网站群发关键词怎么在百度上推广自己的公司信息
  • 网站开发 沈阳免费模板建站
  • 商业性质网站建设步骤wordpress电影网盘
  • 网站的外部推广成都房产网官网
  • 深圳网站建设创想营销北京土巴兔全包装修价格表
  • 怎么发布php网站邯郸建设网站制作
  • 手机网站做多宽的图片wordpress顶部导航栏怎么创建
  • 如何做招聘网站的数据分析安徽黄山旅游攻略
  • 2022建站市场国际新闻直播
  • 茗哥网站建设装饰公司网站规划方案
  • 北京天津网站建设公司做平台网站要多久
  • 做我女朋友的表白句的网站做seo_教你如何选择网站关键词
  • 如何对网站用户分析徐州网站制作如何定位
  • 网站定制生成器龙岗网站设计讯息