• is 和 == 的区别


    is 和 == 操作符的区别

    python官方解释:

    == 的meaning为equal;

    is的meaning为object identity;

    is 判断对象是否相等,即身份是否相同,使用id值判断;
    == 判断对象的值是否相等。
     
    id值是什么?
    id()函数官网解释:
    id(object)
    Return the “identity” of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same id() value.
    CPython implementation detail: This is the address of the object in memory.
     
    返回对象的身份,即在对象生命周期中对象保证唯一不变的整数。不重叠的两个对象可能会有同样的id值。
    对于CPython解释器:id值是对象在内存中的地址。
     
     
    Cpython是什么?
    python解释器用来执行.py文件。从python官网下载并安装好Python后,我们就直接获得了一个官方版本的解释器:CPython。这个解释器是用C语言开发的,所以叫CPython。在命令行下运行python就是启动CPython解释器。CPython是使用最广的Python解释器。


     

  • 相关阅读:
    VUE 源码工具
    elasticsearch 根据主键_id更新部分字段
    Linux下解压文件到其他目录
    centos 7 安装docker
    英语阅读
    将Word文件上传到博客园
    kafka
    ubantu批量下载依赖包+apt命令list
    llvm.20.SwiftCompiler.Compiler-Driver
    Java获取resources文件夹下properties配置文件
  • 原文地址:https://www.cnblogs.com/testfan/p/8082447.html
Copyright © 2020-2023  润新知