str()方法

来源:互联网 发布:海湾调试软件 编辑:程序博客网 时间:2024/05/16 09:08

1. capitalize()

返回首字母大写格式的字符串

 


 2. center(width【,fillchar 】 )

    如果len(string)>width,则只会显示string。

            



s1='hello'
print s1.find('l') #返回索引

print s1.replace('k','m'),s1 #如果要替换的字符串不存在,则不进行其他操作


原创粉丝点击