python帮组文档

class int(x, base=10)

Return an integer object constructed from a number or string x, or return 0 if no arguments are given. If x defines __int__(), int(x) returns x.__int__(). If x defines __trunc__(), it returns x.__trunc__(). For floating point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in radix base. Optionally, the literal can be preceded by + or - (with no space in between) and surrounded by whitespace. A base-n literal consists of the digits 0 to n-1, with a to z (or A to Z) having values 10 to 35. The default base is 10. The allowed values are 0 and 2–36. Base-2, -8, and -16 literals can be optionally prefixed with 0b/0B, 0o/0O, or 0x/0X, as with integer literals in code. Base 0 means to interpret exactly as a code literal, so that the actual base is 2, 8, 10, or 16, and so that int('010', 0) is not legal, while int('010') is, as well as int('010', 8).

个人理解

  • 返回一个整型数据
  • int()---没有参数,直接返回0
  • int(X)---X任意数值,整数直接返回,小数截断返回
  • base-- 进制
      • 有base参数,X必须是一个字符串
      • 将X按照base进制读取,分析
      • 默认是十进制 如 int(‘10’)
      • 返回十进制数

代码演示

int(10.9 int(10)

    

  

Python中的int函数的更多相关文章

  1. Python 中的isinstance函数

    解释: Python 中的isinstance函数,isinstance是Python中的一个内建函数 语法: isinstance(object, classinfo) 如果参数object是cla ...

  2. Python中的map()函数和reduce()函数的用法

    Python中的map()函数和reduce()函数的用法 这篇文章主要介绍了Python中的map()函数和reduce()函数的用法,代码基于Python2.x版本,需要的朋友可以参考下   Py ...

  3. python中如何调用函数交换两个变量的值

    python中如何调用函数交换两个变量的值 所有代码来在python3.7.1版本实现 以下实例通过用户输入两个变量,并相互交换:  方法一: def swap(a,b): # 创建临时变量,并交换 ...

  4. 《python解释器源码剖析》第2章--python中的int对象

    2.0 序 在所有的python内建对象中,整数对象是最简单的对象.从对python对象机制的剖析来看,整数对象是一个非常好的切入点.那么下面就开始剖析整数对象的实现机制 2.1 初识PyLongOb ...

  5. python --- Python中的callable 函数

    python --- Python中的callable 函数 转自: http://archive.cnblogs.com/a/1798319/ Python中的callable 函数 callabl ...

  6. python中使用zip函数出现<zip object at 0x02A9E418>

    在Python中使用zip函数,出现<zip object at 0x02A9E418>错误的原因是,你是用的是python2点多的版本,python3.0对python做了改动 zip方 ...

  7. [转载]python中multiprocessing.pool函数介绍

    原文地址:http://blog.sina.com.cn/s/blog_5fa432b40101kwpi.html 作者:龙峰 摘自:http://hi.baidu.com/xjtukanif/blo ...

  8. python中multiprocessing.pool函数介绍_正在拉磨_新浪博客

    python中multiprocessing.pool函数介绍_正在拉磨_新浪博客     python中multiprocessing.pool函数介绍    (2010-06-10 03:46:5 ...

  9. 举例详解Python中的split()函数的使用方法

    这篇文章主要介绍了举例详解Python中的split()函数的使用方法,split()函数的使用是Python学习当中的基础知识,通常用于将字符串切片并转换为列表,需要的朋友可以参考下   函数:sp ...

随机推荐

  1. h5自带的日期类型input

    在很多页面和web应用中都有输入日期和时间的地方,最典型的是订飞机票,火车票,酒店,批萨等网站. 在HTML5之前,对于这样的页面需求,最常见的方案是用Javascript日期选择组件.这几乎是无可争 ...

  2. springboot(二)

    SpringBoot使用JSP 1.创建一个webapp子项目 2.导入依赖 <!-- 配置springboot的父节点依赖,之后引入就不需要添加version配置了! springboot会自 ...

  3. 关于Windows系统里的事后调试

    我一直在想,应用程序抛出未处理的异常和附加到进程的调试器之间会发生什么.显然这些信息就在我眼皮底下,但我是瞎子.Windows调试器关于事后调试的文档包含了您想要知道的所有详细信息. 最常见的应用程序 ...

  4. Redis存储List

    list中数据可以重复,查询快,增删慢. 存储结构: 1.向List存取数据: 查询list中的全部元素: 第一个进入a,第二个进入b,并将a向后移一位. 上图为从右边插入元素的情况. 2.从两头取出 ...

  5. packr 方便的潜入静态资源文件到golang 二进制文件中

    类似的工具以前有介绍过statik,今天使用的工具是packr 也是很方便的golang tools 安装 go get -u github.com/gobuffalo/packr/packr 或者我 ...

  6. tomcat 配置更改 web 目录

    tomcat 虚拟目录:( 编辑  tomcat/conf/server.xml ) <Host name="localhost" appBase="webapps ...

  7. 回归模型的性能评价指标(Regression Model Performance Evaluation Metric)

    回归模型的性能评价指标(Performance Evaluation Metric)通常有: 1. 平均绝对误差(Mean Absolute Error, MAE):真实目标y与估计值y-hat之间差 ...

  8. mysql 显示表结构

    例子 mysql> show columns from table1; +------------+------------------+------+-----+---------+----- ...

  9. [C++] 类的成员变量和成员方法

    类具有成员变量和成员方法 成员变量用来描述某个对象的具体特征,是静态的,也称为成员属性,这些属性一般设置为私有,仅供类的内部使用. 成员方法用来描述某个对象的具体行为,是动态的,也成为成员函数,这些属 ...

  10. excel矩阵相乘矩阵求逆

    如何用电子表格计算两个矩阵相乘 https://jingyan.baidu.com/article/219f4bf7c9039cde452d3854.html   工具/原料 Microsoft Ex ...