这一章的新的函数:
abs(number) :返回数值的绝对值
bytes(string, encoding[,errors]):用指定的错误行为对给定的字符串进行编码;
cmath.sqrt(number):返回平方根,可以用于负数求平方根;
float(object):将字符串或数字转换为浮点数;
int(object):将字符串或数字转换为整数;
help([object]):提供一个交互的帮助,查询一个函数怎么运行;
input(prompt):以字符串的形式从用户获取输入;
################
math.ceil(number):以浮点数的形式返回数字的上限;
math.floor(number):将数字的底作为浮点数返回;
math.sqrt(number):返回平方根;不用于负数求平方根;
>>> math.ceil(x)
7
>>> math.floor(x)
6
>>> math.sqrt(x)
2.495996794869737
#################
pow(x, y[, z]):返回的 x 的 y 次方(对z 取模);
print(object, …):打印出用空格分隔的参数;
repr(object):返回值以字符串表示;
round(number[, ndigits]):四舍五入到给定精度的数字,整数四舍五入到偶数;
>>> x = 6.23
>>> round(x)
6
>>> round(x,3)
6.23
>>> round(x,4)
6.23
>>> round(x,1)
6.2
str(object):把数值转换为字符串,如果从字节转换,则可以指定编码和错误行为;
上面的内容从 Beginning Python From Novice to Professional (Third Edition)书中整理。