python 零散知识点
便于回顾
learn 11233466
这个作者很懒,什么都没留下…
展开
-
Python wordcloud库
原创 2021-04-21 22:20:37 · 63 阅读 · 0 评论 -
combinations方法和map函数
1.combinations(iterable,r)方法可以创建一个迭代器,返回iterable中所有长度为r的子序列(好像长度为1时,仍为元组形式) import itertools list1=[1,2,3,4] list2=list(itertools.combinations(list1,2)) print(list2) print('\n') list3=[] for c in itertools.combinations(list1,2): list3.append(c) p原创 2021-04-21 11:14:24 · 481 阅读 · 0 评论 -
str.isalpha() 和 str.count(sub)
1.str.isalpha() 如果字符串中的所有字符都是字母或文字,并且至少有一个字符,返回 True ,否则返回 False 。 2.count() 方法用于统计字符串里某个字符出现的次数。 语法:str.count(sub, start= 0,end=len(string)) sub – 搜索的子字符串 start – 字符串开始搜索的位置。默认为第一个字符,第一个字符索引值为0。 end – 字符串中结束搜索的位置。默认为字符串的最后一个位置。 ...原创 2021-04-20 23:48:11 · 334 阅读 · 0 评论 -
maketrans()和translate()
https://blog.csdn.net/weixin_30245867/article/details/98313697?utm_source=app&app_version=4.5.8原创 2021-04-15 23:36:30 · 1219 阅读 · 0 评论 -
字符串去重,字符串转列表,列表转字符串(非纯原创)
1.字符串去重,保持原序列不变 x="hellopython" y=list(set(x)) y.sort(key=x.index)#y此时是列表 x=''.join(y) print(x) helopytn >>> 2.字符串转列表 (1) x="hellopython" y=list(x) print(y) ['h', 'e', 'l', 'l', 'o', 'p', 'y', 't', 'h', 'o', 'n'] >>> (2) >>&g原创 2021-04-15 23:29:16 · 236 阅读 · 0 评论