2.4 python中的字符串、索引和截取 [python入门教程]
来源:互联网 发布:deepin linux安装教程 编辑:程序博客网 时间:2024/06/15 00:35
字符串可以用单引号,双引号,三引号成对括起来,索引用[]界定,切片用[:]来省略和连接,这点类似于Matlab。
>>> s1='Python'>>> s2=' is cool!'>>> str=s1+s2>>> str'Python is cool!'>>> str[0]'P'>>> str[2:5]'tho'>>> str[:2]'Py'>>> str[3:]'hon is cool!'>>> str*2'Python is cool!Python is cool!'>>> '-'*8'--------'>>> str[-1]'!'字符串下标从0开始,最后一个字符的索引是-1。加号来连接,*用来重复。
>>> str2='Python\n is cool!'>>> str2'Python\n is cool!'>>> print str2Python is cool!
0 0
- 2.4 python中的字符串、索引和截取 [python入门教程]
- Python中的字符串索引基本知识
- python 字符串 索引和分片
- python字符串的截取和替换
- python截取中文字符串
- python截取中文字符串
- python 字符串截取
- Python 截取字符串
- python 字符串截取
- python截取字符串操作
- python字符串截取
- python字符串截取
- python 字符串截取
- Python字符串截取
- Python截取字符串
- python截取字符串
- python 字符串截取
- python字符串截取操作
- FusionCharts 3D帕累托图
- iOS多线程系列(1)
- OpenWrt编译目标world的依赖
- 回顾2013,对工作的一点感悟
- Thinking in BigData(四)大数据之“大”的来源与价值
- 2.4 python中的字符串、索引和截取 [python入门教程]
- handler的两种实用方法
- 最新版phonegap环境搭建
- 解决python print延迟问题
- [比较offer] zz:2012年国内IT行业薪水一览表(真实数据,对号入座)
- NPOI 2.0类库的介绍
- 十本HTML5英文原版书籍推荐
- uva 699 The Falling Leaves
- EBS OAF开发中的弹性域(Flexfields)(二)--关键性弹性域及其它