1、绝对值abs(x)
求数值的绝对值
>>> abs(-3.4)
3.4
>>>
2、最小值 min(x)
求最小值
>>> min(10,23,56,4,656,66)
4
>>>
3、最大值max(x)
求最大值
>>> max(10,23,56,4,656,66)
656
>>>
4、算术平方根sqrt(x)
使用前先加载math
>>> import math
>>> math.sqrt(3)
1.7320508075688772
>>>
5、取整ceil(x)
数值向上取整
>>> import math
>>> math.ceil(5.6)
6
>>>
6、向下取整floor(x)
数值向下取整
>>> import math
>>> math.floor(-5.6)
-6
>>> math.floor(5.6)
5
>>>
7、求字符串长度len(x)
>>> len('sdfsdfasdf')
10
>>>
8、将字符串转换成大写str.upper()
>>> str.upper('i love chaina!')
'I LOVE CHAINA!'
>>>
9、将字符串转换成小写str.lower()
>>> str.lower('I LOVE CHAINA!')
'i love chaina!'
>>>
10、字符串中查找指定字符串c str.find(c)
在字符串中查找指定的字符串,如果有返回索引值,没有返回-1
>>> str = 'i love chaina!'
>>> str.find('love')
2
>>> str.find('loves')
-1
>>>
11、字符串替换 str.replace(old,new)
将字符串中old字符串替换成new字符串
>>> str.replace('love','leves')
'i leves chaina!'
>>>
12、去空格 str.strip()
去除字符串str两侧的空格、回车
>>> str = ' i love chaina! \n'
>>> print(str)
i love chaina!
>>> str.strip()
'i love chaina!'
>>>