其他内置函数

all python build in function
click here

raw_input

从终端读取用户输入;

birth = int(raw_input('please input your birth:'))
#raw_input输入的都为字符串,当期望其他类型时,需要进行类型转换;

range

列表生成式 (List Comprehensions)

>>> range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> range(1, 10)
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> [x * x for x in range(1, 11)]
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
>>> [x * x for x in range(1,11) if x % 2 == 0]
[4, 16, 36, 64, 100]

isinstance判断是否是某种数据类型

>>> x = 'abc'
>>> y = 123
>>> isinstance(x, str)
True
>>> isinstance(y, str)
False

来源:https://jingyan.baidu.com/article/4b07be3c64483b48b280f35e.html

你可能感兴趣的:(其他内置函数)