[2020-06-21]python基础回顾

python常见函数

数学函数

pow(a, b) 求a的b次幂

abs(a) 求a的绝对值

round(a) 求距离a最近的整数

sqrt(a) 求开发

input('please input your number: ') 终端输入函数

raw_input('please input your number: ') 终端输入函数

python序列 

索引

索引到第一个元素str[0]

>>> str

'hi,today is Sunday!'

>>> str[0]

'h'

索引到最后一个元素str[-1]

>>> str[-1]

'!'

索引到倒数第二个元素str[-2]

>>> str[-2]

'y'

分片

list[2,4]表示取出2<=index<4之间的元素

>>> list=['a','b','c','1','2','3']

>>> list[2:4]

['c', '1']

 

 

 

猜你喜欢

转载自www.cnblogs.com/liurong07/p/13173236.html