您的位置:首页 > 编程语言 > Python开发

python 字符串函数

2015-10-19 21:14 525 查看
from string import maketrans

title = "come out Linda~"
print title.find("Linda")#9
print title.find("linda")#-1

seq = ["a","b","c","d","e"]
sep = "*"
print sep.join(seq)#a*b*c*d*e

name = "LINDA"
print name.lower()#linda

print "This is a test".replace("is","eez")#Theez eez a test

print "1*2*3*4*5".split("*")#['1', '2', '3', '4', '5']

print '             hello            '
print '             hello            '.strip()#hello
print '@#$%^&hello@#$!%^&'.strip('@#$%^&')#hello@#$!

table = maketrans('cs','kz')
print 'this is a incredible test'.translate(table)#thiz iz a inkredible tezt

print "Done!Tada!!"


#后面是输出结果咯~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: