#create a tuple
tuplex = (, , , , , , , , , )
#used tuple[start:stop] the start index is inclusive and the stop index
_slice = tuplex[:]
#is exclusive
print(_slice)
#if the start index isn't defined, is taken from the beg inning of the tuple
_slice = tuplex[:]
print(_slice)
#if the end index isn't defined, is taken until the end of the tuple
_slice = tuplex[:]
print(_slice)
#if neither is defined, returns the full tuple
_slice = tuplex[:]
print(_slice)
#The indexes can be defined with negative values
_slice = tuplex[-:-]
print(_slice)
#create another tuple
tuplex = tuple("HELLO WORLD")
print(tuplex)
#step specify an increment between the elements to cut of the tuple
#tuple[start:stop:step]
_slice = tuplex[::]
print(_slice)
#returns a tuple with a jump every items
_slice = tuplex[::]
print(_slice)
#when step is negative the jump is made back
_slice = tuplex[::-]
print(_slice)

python 元组切片的更多相关文章

  1. Python 学习笔记(九)Python元组和字典(一)

    Python 元组 元组的定义  元组(tuple)是一种Python对象类型,元组也是一种序列 Python中的元组与列表类似,不同之处元组的元素不能修改 元组使用小括号,列表使用方括号 元组的创建 ...

  2. Python 元组和列表

    Python 元组 Python的元组与列表类似,不同之处在于元组的元素不能修改. 元组使用小括号,列表使用方括号. 元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可. 如下实例: tup1 ...

  3. Python 简明教程 --- 11,Python 元组

    微信公众号:码农充电站pro 个人主页:https://codeshellme.github.io 软件工程的目标是控制复杂度,而不是增加复杂性. -- Dr. Pamela Zave 目录 我们在上 ...

  4. Python元组索引、截取

    Python元组索引.截取: 索引下标: tuple_1 = ('a','b','c','d','e','f','g','h') print(tuple_1[0]) # a print(tuple_1 ...

  5. python 元组tuple介绍,使用。

    原文 https://blog.csdn.net/ruanxingzi123/article/details/83184909 一  是什么? # python 元组tuple? ''' 元祖tupl ...

  6. Python元组

    Python的元组与列表类似,不同之处在于元组的元素不能修改. 元组使用小括号,列表使用方括号. 元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可. 如下实例: tup1 = ('physi ...

  7. python基础——切片

    python基础——切片 取一个list或tuple的部分元素是非常常见的操作.比如,一个list如下: >>> L = ['Michael', 'Sarah', 'Tracy', ...

  8. Python 元组内置函数

    Python元组包含了以下内置函数 序号 方法及描述 1 cmp(tuple1, tuple2)比较两个元组元素. 2 len(tuple)计算元组元素个数. 3 max(tuple)返回元组中元素最 ...

  9. python中切片的理解

    Python中什么可以切片 l  Python中符合序列的有序序列都支持切片(slice) l  如:列表,字符,元祖 Python中切片的格式 l  格式:[start : end : step] ...

随机推荐

  1. Linux实验楼学习之二

    新建文件1-1.c touch 1-1.c 编辑文件1-1.c gedit 1-1.c 生成可执行文件1-1.c gcc -o 1-1 1-1.c 执行可执行文件1-1 ./1-1

  2. Outlier Detection

    1)正态分布数据,飘出95%的可能是异常值.变量var正态标准化,|var|<=1.96的可能是异常值,further chk needed!large sample better. 对于偏态分 ...

  3. pd.read_csv操作读取分隔符csv和text文件

    pandas.read_csv可以读取CSV(逗号分割)文件.文本类型的文件text.log类型到DataFrame 1. pandas.read_csv常用参数整理 也支持文件的部分导入和选择迭代 ...

  4. testng入门教程16数据驱动(把数据写在xml)

    testng入门教程16数据驱动(把数据写在xml) testng入门教程16数据驱动(把数据写在xml)把数据写在xml文件里面,在xml文件右键选择runas---testng执行 下面是case ...

  5. Struts2-综合项目

    综合项目:视频后台管理系统 开发环境:Tomcat6(服务器)+jdk6(windows操作系统) 使用技术:struts2(后台)+jsp(前台显示)+ajax(信息传递)+json(服务器响应前台 ...

  6. http协议基础(九)响应首部字段

    响应首部字段: 服务器向客户端返回响应报文中所使用的字段,用于补充的附加信息.服务器信息.以及对客户端的附加要求等 1.Accept-Ranges 告知客户端服务器能否处理范围请求,以指定获取服务器的 ...

  7. Echarts使用及动态加载图表数据 折线图X轴数据动态加载

    Echarts简介 echarts,缩写来自Enterprise Charts,商业级数据图表,一个纯JavaScript的图表库,来自百度...我想应该够简洁了 使用Echarts 目前,就官网的文 ...

  8. VS2010/MFC编程入门之三十三(常用控件:标签控件Tab Control 下)

    上一节中鸡啄米讲了标签控件知识的上半部分,本节继续讲下半部分. 标签控件的创建 MFC为标签控件的操作提供了CTabCtrl类. 与之前的控件类似,创建标签控件可以在对话框模板中直接拖入Tab Con ...

  9. yii2关联查询两组一对一

    public function getMember1(){        return $this->hasOne(Member::className(), ['wechat_id' => ...

  10. JavaScript实现功能全集

    JavaScript就这么回事1:基础知识 1 创建脚本块 <script language="JavaScript">JavaScript code goes her ...