VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > Python基础教程 >
  • python基础教程之day16-python之函数式编程匿名函数(2)

alex','age':1000}, 10 {'name':'wupei','age':10000}, 11 {'name':'yuanhao','age':9000}, 12 {'name':'linhaifeng','age':18}, 13 ] 14 # print(list(filter(lambda p:p['age']<=18,people))) 15 # print(list(filter(lambda p:p['age']<=18,people))) 16 17 #reduce:处理一个序列,然后把序列进行合并操作 18 from functools import reduce 19 print(reduce(lambda x,y:x+y,range(100),100)) 20 # print(reduce(lambda x,y:x+y,range(1,101)))
复制代码

8.内置函数

复制代码
 1 #!/usr/bin/env python
 2 # -*- coding:utf-8 -*-
 3 # print(abs(-1))
 4 # print(abs(1))
 5 #
 6 # print(all([1,2,'1']))
 7 # print(all([1,2,'1','']))
 8 # print(all(''))
 9 
10 # print(any([0,'']))
11 # print(any([0,'',1]))
12 
13 
14 # print(bin(3))
15 
16 #空,None,0的布尔值为False,其余都为True
17 # print(bool(''))
18 # print(bool(None))
19 # print(bool(0))
20 
21 name='你好'
22 # print(bytes(name,encoding='utf-8'))
23 # print(bytes(name,encoding='utf-8').decode('utf-8'))
24 
25 # print(bytes(name,encoding='gbk'))
26 # print(bytes(name,encoding='gbk').decode('gbk'))
27 #
28 # print(bytes(name,encoding='ascii'))#ascii不能编码中文
29 #
30 # print(chr(46))
31 #
32 # print(dir(dict))
33 #
34 # print(divmod(10,3))
35 
36 # dic={'name':'alex'}
37 # dic_str=str(dic)
38 # print(dic_str)
39 
40 #可hash的数据类型即不可变数据类型,不可hash的数据类型即可变数据类型
41 # print(hash('12sdfdsaf3123123sdfasdfasdfasdfasdfasdfasdfasdfasfasfdasdf'))
42 # print(hash('12sdfdsaf31231asdfasdfsadfsadfasdfasdf23'))
43 #
44 name='alex'
45 # print(hash(name))
46 # print(hash(name))
47 #
48 #
49 # print('--->before',hash(name))
50 # name='sb'
51 # print('=-=>after',hash(name))
52 
53 
54 # print(help(all))
55 #
56 # print(bin(10))#10进制->2进制
57 # print(hex(12))#10进制->16进制
58 # print(oct(12))#10进制->8进制
59 
60 
61 name='哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊哈粥少陈'
62 # print(globals())
63 # print(__file__)
64 #
65 def test():
66     age='1111111111111111111111111111111111111111111111111111111111111'
67     # print(globals())
68     print(locals())
69 #
70 # test()
71 #
72 l=[1,3,100,-1,2]
73 # print(max(l))
74 # print(min(l))
75 
76 
77 
78 # print(isinstance(1,int))
79 # print(isinstance('abc',str))
80 print(isinstance([],list))
81 # print(isinstance({},dict))
82 print(isinstance({1,2},set))
复制代码


相关教程
关于我们--广告服务--免责声明--本站帮助-友情链接--版权声明--联系我们       黑ICP备07002182号