Python字符串定义索引切片加号星号操作实例
发布时间
阅读量:
阅读量
#coding=utf8
print '''
PythonZ中字符串被定义为引号之间的字符集合。
Python支持使用成对的单引号或双引号,三引号(三个连续的单引号或者双引号)可以来包含特殊字符。
使用索引运算符([])和切片运算符([:])可以得到子字符串。
字符串有其特有的索引规则:第一个字符的索引是0,最后一个字符的索引是-1。
加号(+)用于字符串连接运算,星号(*)用于字符串重复。
'''
sgQ='hello world'
doubleQueto="I am ewang"
threeQueto='''
one two three
one add two equal three
'''
print "The single queto string-------->",sgQ
print "The double queto string-------->",doubleQueto
print "The three queto string-------->",threeQueto
print "The use of index----------
全部评论 (0)
还没有任何评论哟~
