Tuples are immutable
A tuple is a sequence of values. The values can be any type, and they are indexed by integers, so in that respect tuples are a lot like lists. The important difference is that tuples are immutable. Syntactically, a tuple is a comma-separated list of values:

To create a tuple with a single element, you have to include the final comma. Without the comma, Python treats (‘a’) as a string in parentheses. Another way to create a tuple is the built-in function tuple. With no argument, it creates an empty tuple.
If the argument is a sequence (string, list or tuple), the result is a tuple with the elements of the sequence. Most list operators also work on tuples. And the slice operator selects a range of elements.

But if you try to modify one of the elements of the tuple, you get an error. You cant modify the elements of a tuple, but you can replace one tuple with another.

from Thinking in Python
Tuples are immutable的更多相关文章
- Think Python - Chapter 12 Tuples
12.1 Tuples are immutable(元组是不可变的)A tuple is a sequence of values. The values can be any type, and t ...
- Python学习笔记(迭代、模块扩展、GUI 、编码处理等)
PythonIDLE中的编码处理 http://www.tuicool.com/articles/NbyEBr 原文标题:Python中实际上已经得到了正确的Unicode或某种编码的字符,但是看起来 ...
- 关于Python中数据对象的可变性
先贴上Python官网中对数据模型描述的几段话.(在python官网的 语言参考>>数据模型 那部分) Every object has an identity, a type and a ...
- Python Tutorial 学习(五)--Data Structures
5. Data Structures 这一章来说说Python的数据结构 5.1. More on Lists 之前的文字里面简单的介绍了一些基本的东西,其中就涉及到了list的一点点的使用.当然,它 ...
- python for data analysis 2nd 读书笔记(一)
第一章相对简单,也么有什么需要记录的内容,主要用到的工具的简介及环境配置,粗略的过一下就行了.下面我们开始第二章的学习 CHAPTER 22.2Python Language Basics, IPyt ...
- Python开发 基礎知識 (未完代補)
一.Python基本知識 1.Python屬高階語言,所編築的是字節碼 2.一般狀態statement 終止於換行,如需使用多數行編寫,可在行末加上 \,以表延續 但在 parentheses ( ) ...
- [Python Essential Reference, Fourth Edition (2009)]读书笔记
Python programs are executed by an interpreter. When you use Python interactively, the special varia ...
- python 删除元组元素
#create a tuple tuplex = "w", "j" ,"c", "e" print(tuplex) #t ...
- A Complete Tutorial to Learn Data Science with Python from Scratch
A Complete Tutorial to Learn Data Science with Python from Scratch Introduction It happened few year ...
随机推荐
- EOSS V3.0.2 企业运营支撑系统(基于RBAC原理的权限管理)
下载地址:https://github.com/jelly-liu/EOSS 一:EOSS 功能介绍 其于用户,角色,权限,资源(即菜单)的一套"简约有用"的权限管理系统,可在其基 ...
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第6章节--在SharePoint2013中开发、集成和构建应用程序 总结
BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第6章节--在SharePoint2013中开发.集成和构建应用程序 总结 SharePoint开发已经 ...
- CC2540/CC2541 : Set the Peripheral Being Advertising while It is Being Connected
There is possible to set your CC254X be scanable when it is in connection. But, based on my test,the ...
- Android自己定义矩形及selector、shape的使用
[声明]转载请注明出处.此文出自指尖飞落的博客:http://blog.csdn.net/huntersnail --每天写一篇博客.每天做一点技术积累! Android自己定义矩形及selector ...
- Oracle RAC --安装图解
规划:所用linux系统以虚拟化方式安装在esx上,配置有内网的yum源,各分配有16G存储,下面为简单拓扑图 一,下载软件1,地址:http://www.oracle.com/technology/ ...
- 20.boost dijkstra最短路径算法
到某个点的最短距离 到终点的最短路径 完整代码 #include <iostream> #include <string> #include &l ...
- MYSQL5.6/5.7 数据库密码丢失问题处理(需重启)
文章结构图: 一.MYSQL5.6密码丢失 1. 强行停止MYSQL 丢失超级管理用户ROOT的密码是致命的,可以通过--skip-grant-tables参数来跳过权限表. 停止MYSQL,强行杀 ...
- Ajax :六个全局事件
加载请求: .ajaxStart() 和 .ajaxstop() $(document).ajaxStart(function(){ $('.loading').show(); }).ajaxStop ...
- 把阅读平台从Acrobat转到Endnote
现在阶段的学习完全到了自学,那么整理文献也必须有自己的一套思路和办法.不像硕士阶段导师给论文,而是自我指导读论文,必须有一种类似版本控制和库的快速调用的机制.而Endnote越来越必须了. 首先遇到的 ...
- NYOJ 16 矩形嵌套【DP】
解题思路:呃,是看的紫书上面的做法,一个矩形和另一个矩形之间的关系就只有两种,(因为它自己是不能嵌套自己的),可嵌套,不可嵌套,是一个二元关系,如果可嵌套的话,则记为1,如果不可嵌套的话则记为0,就可 ...