|
|
发表于 2014-5-29 10:08:35
|
显示全部楼层
class int(object)
| int(x[, base]) -> integer
|
| Convert a string or number to an integer, if possible. A floating
| point argument will be truncated towards zero (this does not include a
| string representation of a floating point number!) When converting a
| string, use the optional base. It is an error to supply a base when
| converting a non-string.
类 int(object)
语法int(x[,base]) __ integer
转换一个字符串或者数字为整型。浮点型数据只保留整数部分(不包括字符串形式的浮点型数字)。当转换一个字符串的时候,base是可选的,这个可以作为转换 非字符串类型的错误表示
如
- >>> int(2, 4)
- Traceback (most recent call last):
- File "<pyshell#32>", line 1, in <module>
- int(2, 4)
- TypeError: int() can't convert non-string with explicit base
复制代码
|
|