s = ’ hello world ’
s.strip()
‘hello world’s.rstrip()
’ hello world’s.lstrip()
'hello world ’s.replace(’ ‘,’’)
‘helloworld’
#将空格替换成无空格s.replace (’ ‘,’-’)
‘-hello-world-’s.replace (’ ‘,’----’)
‘----hello----world----’s
’ hello world ’
#不论怎么更改原来的s字符串没有真正的变化
#replace() #strip()
最新推荐文章于 2021-12-08 23:32:58 发布