
python内置函数
Bad_boys0
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
python3常用的三大函数之一map
lambda函数add = lambda x, y : x+y print(add(1,2))(1)map(func,seq[]) return list对seq 中的item依次执政func(item),返回一个可迭代对象,需要用list/tuple将其接收str = (‘a’, ‘b’,’c’, ‘d’)def fun2(s): return s + “.txt”...原创 2018-09-06 16:17:35 · 927 阅读 · 0 评论 -
python3常用的三大函数之一filter
(2) filter(func,seq) 对seq的item以此执行fun(item),将执行的结果为True的item返回一个可迭代对象a = filter(lambda x: x %3 ==0, range(1,20))print(tuple(a))计算1~100中的平方根是整数import mathdef func(x): return x if math.sqrt(x) i...原创 2018-09-06 16:25:03 · 734 阅读 · 0 评论 -
python3常用的三大函数之一reduce
reduce(func,seq[]) seq中item顺序迭代,调用function,函数必须有两个参数,执行结果返回一个值,在python2是python2中的一个函数在python3中将其放在functoolsfrom functools import *def add(x, y): return x + ya = reduce(add, [0,2,3,4,5],1)pri...原创 2018-09-06 16:38:08 · 2594 阅读 · 0 评论 -
python3内置函数一sorted
sorted()函数的应用,可以自己规定方式排序原创 2018-09-06 16:57:31 · 244 阅读 · 0 评论 -
python3内置函数一Counter
列表里面元素的统计from collections import Countertext1 = "There are moments in life when you miss someone so much that you just want to pick them from your dreams and hug them for real! Dream what you wan...原创 2018-09-07 08:46:40 · 742 阅读 · 0 评论