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. python3 爬虫继续爬笔趣阁 ,,,,,,,

    学如逆水行舟,不进则退 今天想看小说..找了半天,没有资源.. 只能自己爬了 想了半天.,,,忘记了这个古老的技能 捡了一下 import requests from bs4 import Beaut ...

  2. Call to undefined function imagecreatefromjpeg() 让GD支持JPEG格式的图片扩展

    安装扩展支持jpeg格式: 第一步:首先下载文件: 版本v8: wget http://www.ijg.org/files/jpegsrc.v8b.tar.gz 版本v9: wget http://w ...

  3. 设置多个className

    有时候我们需要有选择地设置多个className function myComponent(props) { const myClassName = { 'aaa', {'bbb': props.ne ...

  4. c++ 获取字符串中最长的回文子串

    #include <vector> #include <iostream> #include <string> using namespace std; strin ...

  5. Swarm容器集群管理(超详细)

    一.Swarm介绍 Swarm是Docker公司自研发的容器集群管理系统, Swarm在早期是作为一个独立服务存在, 在Docker Engine v1.12中集成了Swarm的集群管理和编排功能.可 ...

  6. Don't always upset yourself !

  7. SpringBoot框架 之 Druid与Swagger2

    目录 Druid Druid连接池配置 Druid数据监控 集成Swagger2 Swagger2简介 1.添加依赖 2.创建Swagger2配置类 3.在控制器方法上添加对应api信息 4.启动Sp ...

  8. fastJson反序列化参数为null的问题

    fastJson反序列化为类对象时,反序列化赋值的属性只会是你构造器上写的属性. 所以部分属性值为null的原因是属性没有加在构造器上的原因. 直接加个无参数的默认构造器即可解决.或者把null属性加 ...

  9. C# 反射、使用场景

    创建一个 Console 控制台应用程序, 1. 创建一个 Project 类 public class Project { public int ID { get; set; } public st ...

  10. cesium常用设置【转】

    https://blog.csdn.net/D_Walker/article/details/82188514 1.加载线上cesium代码<link href="http://ces ...