博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
内置函数 集锦
阅读量:4326 次
发布时间:2019-06-06

本文共 1178 字,大约阅读时间需要 3 分钟。

1 #input() 2 #print() 3 #int 4 #float 5 #dict(a=1,b=2) 6 #list('123') 7 #set() 8 #tuple() 9 #bool10 #type11 #id12 #len13 print(bool(''))14 print(bool(None))15 print(bool([]))16 print(bool({}))17 print(bool(()))18 print(bool(0))19 20 sum([1,2,3,4,5])21 max()22 min()23 print(round('1.999',2))#保留几位小数24 print(divmod(10,5))#取余数25 print(globals())#把当前文件中的所有的变量取出来26 print(locals())27 28 def abc():29     print(locals()) #取函数里面的所有的局部变量30     print(globals()) #取整个python文件里面的所有变量31 abc()32 33 print(chr(65)) #ascii码对应的字符34 print(ord('a')) #字符对应的ascii码35 36 d = {}37 l = []38 print(dir(d))#查看有哪些方法39 # print(help(l))40 41 enumerate #枚举42 l = ['a','b','c','d','e','f']43 44 #实现45 #a > =146 #b > =247 #c > =348 #d > =449 #e > =550 51 #第一种方法52 id = 153 for i in l:54     print('%s=>%s'%(i,id))55     id+=156 57 for id,i in enumerate(l,1):58     print('%s->%s'%(id,i))59 60 l1=['xiaohei','xaobai','haha']61 l2=[110,120,130]62 res = list(zip(l1,l2))  #把list整合到一起63 print(res)64 print(dict(res))#由于是一对一的关系,所以可以转换成字典65 运行结果:[('xiaohei', 110), ('xaobai', 120), ('haha', 130)]66                  {
'xiaohei': 110, 'xaobai': 120, 'haha': 130}

 

转载于:https://www.cnblogs.com/baiby/p/10775916.html

你可能感兴趣的文章
CYQ.Data V5 MAction新增加SetExpression方法说明
查看>>
数据安全&MD5加密
查看>>
bzoj 2594: 水管局长数据加强版 Link-Cut-Tree
查看>>
世界是数字的观后感
查看>>
由DBCursor的“can't switch cursor access methods”异常引发的思考
查看>>
LUOGU P1438 无聊的数列 (差分+线段树)
查看>>
引用和指针的区别
查看>>
stm32 usart 异步传输示例
查看>>
yum 安装过程下载的包存放路径
查看>>
二叉树
查看>>
idea下http响应乱码
查看>>
jquery使用$.each()
查看>>
Sybase 15.7 开发版下载(非注册)
查看>>
P1527 [国家集训队]矩阵乘法
查看>>
java 包(package)
查看>>
android Service介绍
查看>>
[MySQL 5.6] GTID实现、运维变化及存在的bug
查看>>
css钻石旋转实现
查看>>
sencha touch list infinite 属性
查看>>
指令——cat
查看>>