#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. 阿里云安装docker 指定版本

    sh docker-install.sh 1.12.6 #ubuntu16.4 测试通过 #!/bin/sh set -e # # This script is meant for quick &am ...

  2. [LeetCode] 605. Can Place Flowers_Easy

    Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, ...

  3. Hadoop集群安装-CDH5(3台服务器集群)

    CDH5包下载:http://archive.cloudera.com/cdh5/ 主机规划: IP Host 部署模块 进程 192.168.107.82 Hadoop-NN-01 NameNode ...

  4. mysql服务器上的mysql这个实例中表的介绍

    1.user表. 分个分隔符

  5. 集合框架—HashMap

    HashMap提供了三个构造函数:       HashMap():构造一个具有默认初始容量 (16) 和默认加载因子 (0.75) 的空 HashMap.       HashMap(int ini ...

  6. linux centos系统下升级python版本

    本文参考资料:https://www.cnblogs.com/leon-zyl/p/8422699.html,https://blog.csdn.net/tpc1990519/article/deta ...

  7. 2018-2019-2 20165209 《网络对抗技术》Exp3:免杀原理与实践

    2018-2019-2 20165209 <网络对抗技术>Exp3:免杀原理与实践 1 免杀原理与实验内容 1.1 免杀原理 一般是对恶意软件做处理,让它不被杀毒软件所检测.也是渗透测试中 ...

  8. Linux基础命令---mkisofs

    mkisofs mkisofs指令可以创建ISO9660/Joliet/HFS文件系统,现在使用指令genisoimage代替它.genisoImage是一个预掌握程序,用于生成iso 9660/jo ...

  9. Js基础知识3-字符串、正则表达式全解

    字符串的生成转换 你可以将任何类型的数据都转换为字符串,你可以用下面三种方法的任何一种: var myStr = num.toString(); // "19" var myStr ...

  10. python之路----黏包的解决方案

    黏包的解决方案 远程执行命令 # server 下发命令 给client import socket sk = socket.socket() sk.bind(('127.0.0.1',8080)) ...