标签:eval font htm == style ack false tuple else
https://docs.python.org/3/library/functions.html#next
bin()二进制
oct()八进制
int()十进制
str()字符串
t=ord(‘a‘)
print(t,type(t))
n = chr(65)
print(n,type(n))
运行结果
97 <class ‘int‘>
A <class ‘str‘>
==================================
t=max([11,22,33])
print(t)
n=min([11,22,33])
print(n)
m=len([11,22,33])
print(m)
sum=sum([11,22,33])
print(sum)
sum1=eval(‘1 + 2 + 3‘)
print(sum1)
运行结果
33
11
3
66
6
==========================================
isinstance()为判断是否是一个字符串,数组,元组,字典等,为真为True为假为False
ret = isinstance([11,22,33],str)
print(ret)
运行结果为False
ret = isinstance([11,22,33],list)
print(ret)
运行结果为True
=============================================================
next()可迭代反回下一下元素直到耗尽,StopIteration报错
s=iter([11,22,33])
t=next(s)
print(t)
t1=next(s)
print(t1)
t2=next(s)
print(t2)
t3=next(s)
print(t3)
运行结果
11
22、
33
Traceback (most recent call last):
File "H:/python17/s29.py", line 135, in <module>
t3=next(s)
StopIteration
========================
globals()列出全局变量
locals()局部变量
====================================
zip()
x=[1,2,3]
y=[4,5,6]
zipped=zip(x,y)
print(list(zipped))
x1,y1=zip(*zip(x,y))
print(x1)
print(y1)
运行结果
[(1, 4), (2, 5), (3, 6)]
(1, 2, 3)
(4, 5, 6)
标签:eval font htm == style ack false tuple else
原文地址:http://www.cnblogs.com/wang43125471/p/7623557.html