Python - int() 函数
Python int() 函数将指定的值转换为整数。
int() 函数将返回一个由数字或字符串(假设为 x)构造的整数对象,或者在未指定任何参数的情况下返回 0。
语法
int(value, base)
int(x, base=10)
value = 可以转换为整数的数字或字符串
base = 表示数字格式的数字。默认值 - 10
示例
# int() for integers
int(10)
10
int(20)
20
# int() for floating point numbers
int(11.2)
11
int(9.9e5)
990000
- 相关文章
- 区分 C 中的 int main 和 int main(void) 函数
- Python 程序将 int 转换为指数
- Java 中方法 fill(int[], int fromIndex, int toIndex, int val) 的作用是什么?
- 如何在 Python 中将字节转换为整数?
- 如何在 Python 中将 int 转换为字符串?
- const int*, const int * const 和 int const * 在 C 中的区别
- MySQL 中的 int(5) 与 int(10)
- 如何在 Python 中将十六进制字符串转换为 int?
- const int*, const int * const 和 int const * 在 C/C++ 中的区别?
- const int*, const int * const 和 int const * 之间有什么区别?
- Java 中方法 sort(int[] a, int fromIndex, int toIndex) 的作用是什么?
- Java 中方法 copyOfRange(int[] original, int from, int to) 的作用是什么?
- 如何在 Python 中连接 str 和 int 对象?
- Java 中方法 fill(obj[], int fromIndex, int toIndex, int val) 的作用是什么?
- Python zip() 函数