#abs()取绝对值
'''
all(iterable)
Return True if all elements of the iterable are true (or if the iterable is empty).
'''
print(all([0,9,-8,'a']))
print(all([9,-8,'a']))
'''
any(iterable)
Return True if any element of the iterable is true. If the iterable is empty, return False.
'''
print(any([0,9,-8,'a']))
print(any([])) # ascii(object)
# As repr(), return a string containing a printable representation of an object,
# but escape the non-ASCII characters in the string returned by repr() using \x, \u or \U escapes.
a=ascii(['a',1,'汉子'])
print(a,[a])
print(type(a))#格式是字符串
'''
bin(x)
Convert an integer number to a binary string prefixed with “0b”.
'''
print(bin(3))
#布尔bool
print(bool(0))
print(bool(1))
print(bool([]))
#byte
a=bytes('abc',encoding='utf-8')
print(a.capitalize(),a)#字符串不可以修改,二进制的字节格式也不可以修改,要想修改只能生成新的
#bytearray字节的数组可以被修改
b=bytearray('abc',encoding='utf-8')
print(b[0],b[2])
#b[0]='B'#错误。必须以字节形式修改
b[0]=65
b[1]=66
b[2]=67
print(b)
'''
callable(object)判断是否可以被调用
'''
print(callable([]))
def diaoyong():pass
print(callable(diaoyong))#函数和类都可调用
# chr(i),i必须是数字,将数字转为ascll码字符
print(chr(67))
#ord与chr相反
print(ord('C'))
#compile()
code1='for i in range(10):print(i)'
exec(code1)#以下两行程序同等此行
# c=compile(code1,'','exec')#exec将字符串编码可执行的程序
# exec(c)
#print(c),c是内存中的数据对象
code2='1+3/2*6'
print(eval(code2)) #以下两行程序同等此行
'''
c=compile(code2,'','eval')
eval(c)#,适合字符串变字典,以及加减乘除类,不适合语句类,比如for循环,这样的用exec
'''
code3='''
import time
def consumer(name):
print("%s 准备吃包子啦!" %name)
while True:
baozi = yield
print("包子[%s]来了,被[%s]吃了!" %(baozi,name))
c=consumer('猪小芳')
c.__next__()
b1='韭菜馅'
'''
exec(code3)#以下两行程序同等此行
# py_obj=compile(code3,'err.log','exec')#编译过程中出的错会写到err.log中,写不写无所谓,不好使
# exec(py_obj)
#complex复数
print(complex('1+2j')+complex('2+2j'))
#dict字典
print(dict())#生成字典
#dir查看使用方法
a={}
b=()
print(dir(a))
print(dir(b))
#divmod(a,b),return商和余数
print(divmod(6,4))
#匿名函数,用完就释放
(lambda n:print(n*n))(5)#一种传递参数的方法
calc=lambda n:print(n*n)
calc(10)
# calc2=lambda x:for i in range(x):print(i)#处理不了复杂的,可以处理三元运算这种简单的
calc3=lambda n:3 if n<4 else n
print(calc3(5))
#lambda可与filter过滤器结合使用
res=filter(lambda n:n>5,range(10))
print(res)#迭代器
for i in res:
print(i,end='\t')
print('>>>>>>>>>分隔符1')
#lambda可与map结合使用
res=map(lambda n:n*2,range(10))#等价于[i*2 for i in range(10)],[lambda n:n*2 for i in range(10)]
print(res)#迭代器
for i in res:
print(i,end='\t') print('>>>>>>>>>分隔符1')
import functools
print(functools.reduce(lambda x,y:x*y,range(1,10)))#阶乘
print(functools.reduce(lambda x,y:x+y,range(10)))#累加和
#不可变集合,就和元组似的
a=frozenset([1,4,333,212,33,33,12,4])
print(a)
#返回本文件程序的所有全局变量及值
print(globals())
'''
hash(object)哈希:每个数据对应一个数字映射,便于查找
Return the hash value of the object (if it has one).Hash values are integers.
They are used to quickly compare dictionary keys during a dictionary lookup.
Numeric values that compare equal have the same hash value
(even if they are of different types, as is the case for 1 and 1.0).
'''
print(hash('熊羚羽'))
print(hash('韩江桦'))
print(hash('俞莎莎'))
print(hash('熊羚羽'))#与第一个对应的映射是相同的

最新文章

  1. weiphp布署在sina sae图片显示不了问题
  2. iOS coreData问题
  3. LoadRunner中文乱码问题解决方案
  4. Oracle sqlldr导入导出txt数据文件详解
  5. [ActionScript 3.0] AS3 双A字模型
  6. T-SQL语句查看作业等信息
  7. SpringMVC的form:form表单的使用
  8. 数据转换失败 java.math.BigDecimal cannot be cast to java.lang.String
  9. JS区分对象类型
  10. mysql 主从库同步
  11. Codeforces 1089E - Easy Chess - [DFS+特判][2018-2019 ICPC, NEERC, Northern Eurasia Finals Problem E]
  12. Java高编译低运行错误(ConcurrentHashMap.keySet)
  13. npm run dev 报错:missing script:dev
  14. Andriod ----配置环境变量
  15. 用node.js模拟服务器和客户端
  16. BlockingQueue介绍及使用
  17. Thunder——爱阅app(测评人:方铭)
  18. Linux知识(7)----远程登录 和远程拷贝
  19. 配置Kafka集群和zookeeper集群
  20. 算法——(5)B/B+/红黑树

热门文章

  1. 洛谷P4707 重返现世(扩展MinMax容斥+dp)
  2. HDFS(Hadoop Distributed File System )hadoop分布式文件系统。
  3. 数据返回正常 而header头Status=500
  4. Unity---MonoBehaviour9大生命周期
  5. C++基本变量类型
  6. 关于map 及 map 骚操作
  7. jmeter csv中获取带引号的数据详情(转)
  8. 关于JSON可能出现的错误,待更/todo
  9. FZU Problem 2238 Daxia &amp; Wzc&#39;s problem
  10. 牛客网Java刷题知识点之表达式类型的自动提升