标签:
双引号
c1="sldkjf"
print c1
c2="It‘s a dog"
print c2
单引号
c1=‘sldkjf‘
print c1
c2=‘It"s a dog‘
print c2
三引号
c1=‘‘‘jfjsd
sdfsdf
gfg
sgsdgsd
hello‘‘‘
print c1
转义符
print ‘It\‘s a dog‘
print "Hello boy\nhello boy"
自然字符串
print r"Hello boy\nhello boy"
字符串的重复
print "Hello girl\n"* 20
子字符串
索引运算符从0开始索引
切片运算符[a:b]是指从第a下标开始到第b-1下标,同样第一位的下标为0
c1="jekexeyuan"
c2=c1[0]
c3=c1[7]
c4=c1[:2]
c5=c1[2:]
c6=c1[4:7]
print c6
标签:
原文地址:http://www.cnblogs.com/mylovemygirl/p/5058318.html