【python】字典处理

编程入门 行业动态 更新时间:2024-10-09 18:22:41

【python】<a href=https://www.elefans.com/category/jswz/34/1770269.html style=字典处理"/>

【python】字典处理

已知字符串s="When in the course of human events,it becomes necessary for one people to dissolve the political bands which have connected them with another,and to assume among the Powers of the earth,the separate and equal station to which the Laws of Nature and of Nature's God entitle them,a decent respect to the opinions of mankind requires that they should declare the causes.",编写程序,实现如下功能。

  • 输出按不重复单词(不区分大小写)的长度的降序排列的列表。
  • 生成一个新字典,字典的关键字是单词长度,字典的值是长度相同的单词放在一起组成的列表。输出新字典。

s=s.lower().replace(","," ").replace("."," ")

lst1=list(set(s.split()))

#print(lst1)

print("按不重复单词长度降序排列的列表为:")

更多推荐

【python】字典处理

本文发布于:2024-03-12 19:36:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1732253.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字典   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!