标签:开头 name stars 代码 图片 左右 alt str join()
>>> name = "Sheep Core " >>> name.rstrip() ‘Sheep Core‘ #已经去掉末尾空格
>>> name = " Sheep Core" >>> name.lstrip() ‘Sheep Core‘ # 已经去掉字符串中开头的多个空格
>>> name = " Sheep Core " >>> name.strip() ‘Sheep Core‘ # 已经去掉字符串左右两边冗余的空格
# replace(old, new, count)
>>> stars = " I love you " >>> stars.replace(" ", "*") ‘**I*love*you**‘ # 已将空格全部替换成星星
>>> a = "I love python" >>> b = a.split() >>> b [‘I‘, ‘love‘, ‘python‘] >>> " ".join(b) ‘I love python‘
标签:开头 name stars 代码 图片 左右 alt str join()
原文地址:https://www.cnblogs.com/liuxingxing/p/13234258.html