![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python基础
文章平均质量分 69
crane_feng
这个作者很懒,什么都没留下…
展开
-
字符串、列表、元组、字典、集合 差异及关联
字符串、列表、元组、字典、集合 差异及关联 可迭代对象: 字符串,列表,元组,字典,集合,固定集合 可变容器: 列表,字典(无序),集合(无序), 不可变容器: 元组,固定集合(无序) 序列:字符串,列表,元组 集合,固定集合不重复元素 字典不重复键 字面值表示方法: 字符串 列表 元组 字典 ...原创 2018-04-15 20:31:51 · 767 阅读 · 0 评论 -
list 去重的4种方法
方法1(先排序) def removeSame(L,x=0): L.sort() #把列表按从小到大的顺序排列 num = len(L)-1 for x in range(num): if L[x] == L[x+1]: L.remove(L[x+1]) return removeSame(L,x...原创 2018-07-18 18:51:48 · 2259 阅读 · 0 评论 -
用Python实现统计一篇英文文章内内个单词出现的频率, 并返回频率最高的前十个单词及次数(标点符号可省略)
import re with open('1.txt', 'r') as f: dictResult = {} # 每次读取一行的文件 while True: line = f.readline() if not line: break listMatch = re.findall('\w+',...转载 2018-07-30 18:28:25 · 9892 阅读 · 3 评论