函数
来源:互联网 发布:经传多盈软件 编辑:程序博客网 时间:2024/06/05 17:54
#coding=utf-8import time;def getstr(): return "aa"def getNum(): a=1 b=2 return a+bdef getLocalTime(): tm=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime()) return tm#缺省参数def test(v1,v2=1): print v1,v2 return#不定长参数def test1(v1,*v2): print v1 for s in v2: print s return#lambda表达式suma=lambda arg1,arg2:arg1+arg2;'''str=getstr()print str''''''num=getNum()print num''''''tm=getLocalTime()print tm'''# test('haha')# lt=[1,2,3,4,5,6,7]# test1('haha',lt)# print suma(10,2)'''#filterlt=[1,2,3,4,5,6,7]nlt=filter(lambda x:x%2==0,lt)print nlt''''''#maplt=[1,2,3,4,5,6,7,8]nlt=map(lambda x:x+1,lt)print nlt''''''#reducelt=[1,2,3,4,5]print reduce(lambda x,y:x+y,lt)''''''#for..in..iflt=[1,2,3,4,5,6,7]print [x for x in lt if x%2==0]'''
阅读全文
0 0
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- Django settings.py配置文件
- android gradle tools 3.X 中依赖,implement、api 指令
- ssh-port-redirect-in-linux-system
- 解决sql查询时间缺失
- centos 如何关闭防火墙?
- 函数
- js中数组的基本操作
- Spirng+redis 2、实现RedisConfiguration
- 通过commons-fileupload实现文件上传
- SSO单点登录初探
- 技术方向的选择
- android5.1 增加ethernet设置(DHCP与Static ip)
- springmvc登录拦截器访问报错 SyntaxError: expected expression, got '<'
- 使用OAuth2的SSO分析