python中字符串定义、索引、切片、加号、星号操作实例
来源:互联网 发布:苹果手机数据备份 编辑:程序博客网 时间:2024/05/16 06:11
#coding=utf8print '''PythonZ中字符串被定义为引号之间的字符集合。Python支持使用成对的单引号或双引号,三引号(三个连续的单引号或者双引号)可以来包含特殊字符。使用索引运算符([])和切片运算符([:])可以得到子字符串。字符串有其特有的索引规则:第一个字符的索引是0,最后一个字符的索引是-1。加号(+)用于字符串连接运算,星号(*)用于字符串重复。'''sgQ='hello world'doubleQueto="I am ewang"threeQueto='''one two threeone add two equal three'''print "The single queto string-------->",sgQprint "The double queto string-------->",doubleQuetoprint "The three queto string-------->",threeQuetoprint "The use of index------------->",sgQ[0],sgQ[1],sgQ[2],sgQ[-1]print "The use of slice------------->",doubleQueto[:8],doubleQueto[:-1],doubleQueto[3:],doubleQueto[0:5]stringAdd=sgQ+","+doubleQuetoprint "%s + , + %s = %s" %(sgQ,doubleQueto,stringAdd)stringStar=sgQ * 5print "the string uses the star operator:" ,stringStar
0 0
- python中字符串定义、索引、切片、加号、星号操作实例
- Python中字符串切片操作
- Python中序列的切片和加号
- python学习:字符串切片操作
- [Python] 对字符串,列表的切片操作
- Python切片索引
- python 索引 切片 1
- Python中尽量少用加号“+”连接字符串的原因
- Python中定义字符串
- Python中定义字符串
- python中的字符串切片
- python中的字符串切片
- python对字符串切片
- Python 切片操作
- python切片操作
- 【Python】切片操作符
- python-切片操作符
- Python切片操作
- mysql 笔记
- 在eclipse中创建maven项目
- 3年工作经验面试需要掌握的技术
- Comodo Dragon之模拟手机浏览器(iOS/Android)
- JVM初探- 内存分配、GC原理与垃圾收集器
- python中字符串定义、索引、切片、加号、星号操作实例
- 矩阵链乘法问题
- Android中的回调
- Bootstrap可编辑表格
- 修改 Android 5.1 默认设置
- Ubuntu搭建VPN服务
- 快速排序算法
- Definition of Machine Learning
- 解决Eclipse建Maven项目Dynamic web Module无法转换为2.5