`

Python note

阅读更多
0. Object and Value
>>> a = 'banana'
>>> b = 'banana'
>>> a is b
True

In this example, Python only created one string object, and both a and b refer to it.
  >>> a = [1, 2, 3]
  >>> b = [1, 2, 3]
  >>> a is b
  False

  In this case we would say that the two lists are equivalent, because they have the same elements, but not identical, because they are not the same object. If two objects are identical, they are also equivalent, but if they are equivalent, they are not necessarily identical.

>>> a = [1, 2, 3]
>>> b = a
>>> b is a
True
>>> b.append(4)
>>> a is b
True
>>> print a
[1, 2, 3, 4]


1.
>>> eng2sp = dict()
>>> eng2sp['one'] = 'uno'
>>> vals = eng2sp.values()
>>> 'uno' in vals
True

The in operator uses different algorithms for lists and dictionaries. For lists, it uses a search algorithm. As the list gets longer, the search time gets longer in direct proportion. For dictionaries, Python uses an algorithm called a hashtable that has a re-markable property: the in operator takes about the same amount of time no matter how
many items there are in a dictionary.
分享到:
评论

相关推荐

    Ferrero的Pythonnote

    【Pythonnote】是初学者在探索Python编程过程中积累的一份宝贵资源,主要包含了从书籍《Python王者归来》等经典教材中摘录的代表性代码片段。这些代码片段旨在帮助学习者理解Python的基础语法、数据结构、控制流程、...

    python note 基础

    很基础 python 繁体 实例 简单 很基本的python教程,里面多是实例来表示,理论的东西很少。

    PythonNote(中).rar

    《PythonNote(中)》这份文档是针对已经具备一定Python基础知识的学习者而设计的复习资料。它涵盖了Python语言的关键概念、语法以及常见问题,旨在帮助读者巩固和深化对Python的理解。下面将对其中可能涉及的知识点...

    python note.doc

    Python是一种高级编程语言,以其简洁明了的语法和强大的功能而受到广泛的欢迎。在Python学习过程中,基础语法和数据类型是入门的关键。 Python中的数据类型分为内置数据类型和标准库数据类型。内置数据类型包括整型...

    python-note(DOC48页) 精品文档.doc

    "Python Note"文档涵盖了Python的基础知识和一些实用技巧,包括Python的特性、版本差异、交互式环境、集成开发环境(IDE)的配置与卸载、代码注释、基本运算符、数据结构、流程控制以及字符串操作等多个方面。...

    python_note.pdf

    1. Python版本:文件中提到了Python 2.6、Python 2.7和Python 3,这指的是Python的不同版本。Python 2和Python 3在语法和标准库方面有所不同,而且它们之间不完全兼容。Python 3是较新的版本,它包含了很多改进,...

    python_note_个人python的入门心得_

    "python_note_个人python的入门心得_" 这个标题表明这是一个关于个人学习Python的心得体会,可能包含了作者在自学过程中的关键学习点和经验分享。 首先,Python作为一种高级编程语言,它的魅力在于其易读性,它使用...

    Python凯撒密码笔记:原理与实践.md

    decrypted_note = caesar_decrypt(encrypted_note, key) print("Decrypted Note:", decrypted_note) ``` 通过这种方式,即便笔记被其他人看到,他们也无法直接理解笔记内容,从而确保了笔记的安全性。 综上所述,...

    python-note 菜鸟学习笔记.zip

    "python-note 菜鸟学习笔记"可能包含了关于Python编程的基础概念,例如变量、数据类型(如整型、浮点型、字符串、布尔型)、流程控制(条件语句if-else、循环for、while)、函数定义和调用、模块导入等。 在Python...

    Python库 | notetool-0.5.10.tar.gz

    《Python库notetool-0.5.10:深入解析与应用》 在Python的广阔天地里,各种库如繁星般璀璨,为开发者提供了强大的功能支持。今天我们要聚焦的便是其中的一颗明星——"notetool",具体版本为0.5.10,封装在一个名为...

    python_note_202203.py

    python_note_202203.py

    Python库 | notetool-0.4.0-py3.7.egg

    标题中的"Python库 | notetool-0.4.0-py3.7.egg"指的是一款名为`notetool`的Python库,版本号为0.4.0,适用于Python 3.7环境。这个库是通过`.egg`格式进行打包的,这是一种Python的软件分发格式,便于安装和管理。 ...

    自己学习Python的note.zip

    "自己学习Python的note.zip"很可能是包含了作者在自学Python过程中积累的各种资料和心得。这个压缩包可能包含了代码示例、概念解释、项目实践等内容,旨在帮助初学者系统地理解和掌握Python这门编程语言。 Python是...

    python_note(DOC48页).doc

    python_note(DOC48页).doc

    Python库 | python_gist_note-0.2.2-py2-none-any.whl

    `python_gist_note-0.2.2-py2-none-any.whl` 是一个Python库的压缩包文件,它主要用于与GitHub的Gist服务交互。 Gist是GitHub提供的一项服务,允许用户创建和分享代码片段或文本,这些片段被称为Gists。它们可以...

    python-3.7.2-amd64

    Python 3.7.2 是一个重要的编程语言版本,尤其对于使用AMD64架构(也称为x86_64)的计算机系统。这个版本带来了许多改进和新特性,是Python 3.x系列中的一个重要里程碑。它不支持Windows XP或更早的操作系统,因为...

    sqlalchemy-python-learn-note

    sqlalchemy-python-learn-note

    第一节python_note重难点.pdf

    "第一节python_note重难点.pdf"主要涵盖了Python的基本概念、安装配置、常用操作以及编程基础。 首先,Python的一大特性是其解释性,这意味着你可以直接在Python环境下逐行执行代码,无需预先编译。Python3版本对...

    Python库 | notetool-0.6.14-py3-none-any.whl

    在给定的资源中,我们关注的是`notetool-0.6.14-py3-none-any.whl`这个Python库,它是一个预编译的轮子(wheel)文件,特别适用于Python 3环境。 首先,我们要理解什么是Python的轮子文件。轮子文件是Python的二...

    Python For Windows 3.6.5 含32位和64位两个版本

    Python是一种高级、通用的编程语言,以其简洁明了的语法和强大的功能而受到广大程序员的喜爱。在Windows操作系统上,Python提供了官方的安装包,便于用户进行安装和使用。本资源"Python For Windows 3.6.5"包含了...

Global site tag (gtag.js) - Google Analytics