Python 切片(6)
来源:互联网 发布:mac比较好的画图软件 编辑:程序博客网 时间:2024/06/05 15:19
对list进行切片
>>> L = ['Adam', 'Lisa', 'Bart', 'Paul']
>>> L[0:3]['Adam', 'Lisa', 'Bart']
>>> L[:3]['Adam', 'Lisa', 'Bart']
>>> L[1:3]['Lisa', 'Bart']
>>> L[:]['Adam', 'Lisa', 'Bart', 'Paul']
>>> L[::2]['Adam', 'Bart']
倒序切片
>>> L[-2:]['Bart', 'Paul']>>> L[:-2]['Adam', 'Lisa']>>> L[-3:-1]['Lisa', 'Bart']>>> L[-4:-1:2]['Adam', 'Bart']
对字符串进行切片
>>> 'ABCDEFG'[:3]'ABC'>>> 'ABCDEFG'[-3:]'EFG'>>> 'ABCDEFG'[::2]'ACEG'
阅读全文
0 0
- Python 切片(6)
- Python——6切片
- python 切片
- Python 切片
- python--切片
- Python-切片
- Python - 切片
- python 切片
- python 切片
- python 切片
- Python(切片)
- Python 切片
- python-切片
- python切片
- Python 切片
- Python 切片
- Python 切片
- Python切片
- 初学python:输入某年某月某日,判断这一天是这一年的第几天
- 关于json字符串转换成json对象、HashMap和实体类的操作
- Unable to add window -- token android.os.BinderProxy@bf4921f is not valid
- linux下的软件管理
- HYSBZ
- Python 切片(6)
- opencv学习——计算轮廓中心点、周长、面积及近似
- Linux系统识别新增串口设备方法
- 第四章、Javac编译原理
- 汇编小结
- jasperreports在linux环境和Windows环境下字体的设置
- java中的继承和向上转型
- 第25篇.mysql远程连接不上修改
- C#资源释放及Dispose、Close和析构方法