python 内建函数
2016-01-14 11:13
411 查看
zip(x,y,z)
In [1]: x = [1, 2, 3]
In [2]: y = [4, 5, 6]
In [3]: xyz = zip(x, y, z)
xyz
[(1, 4, 7), (2, 5, 8), (3, 6, 9)]
hash:
In [11]: print hash('abc')
1453079729188098211
def function(n):
return n*2
def myfilter(n):
if n !=0:
return 1
def is_even(x):
return x and 1 != 0
b=map(lambda x:x*2,mylist)
d = reduce(lambda x, y: x + y, [2, 3, 4, 5, 6], 1)
c=filter(is_even,mylist)
print d
In [1]: x = [1, 2, 3]
In [2]: y = [4, 5, 6]
In [3]: xyz = zip(x, y, z)
xyz
[(1, 4, 7), (2, 5, 8), (3, 6, 9)]
hash:
In [11]: print hash('abc')
1453079729188098211
coding:utf-8
mylist=[1,2,3,4,5,7,5,7,8,8]def function(n):
return n*2
def myfilter(n):
if n !=0:
return 1
def is_even(x):
return x and 1 != 0
b=map(lambda x:x*2,mylist)
d = reduce(lambda x, y: x + y, [2, 3, 4, 5, 6], 1)
c=filter(is_even,mylist)
print d
相关文章推荐
- 在Window平台下安装xgboost的Python版本
- 最受欢迎的15个Python开源框架
- python Lambda, filter, reduce and map
- 异步非阻塞IO的Python Web框架--Tornado
- Python if __name__ == "__main__" 的含义
- Python 包工具之间的关系
- iOS程序员如何使用python写网路爬虫
- python Django模板的使用方法
- python3.x与2.x区别
- python基础:python的局部变量和全局变量
- python基础之编写第一个python脚本
- 如何使用 Python 创建一个 NBA 得分图?
- Python一行命令/脚本升级所有已安装的第三方包
- 如何使用 Python 创建一个 NBA 得分图?
- Python学习笔记——实例方法和静态方法
- python watchdog:监控文件系统事件的Python库
- python 排列组合
- Python“Non-ASCII character 'xe5' in file”报错问题
- Python 第一篇:python简介和入门
- Python集合