str常用方法

s = “abcdefg”

s1 = s.capitalize()           # 首字母大写,其余小写

s2 = s.upper()                 # 全部大写

s3 = s.lower()                 # 全部小写

s4 = s.swapcase()          # 大小写翻转

s5 = s.title()                    # 把每个隔开单词的首字母字母大写

s6 = s.center(20,"#")  例如 :-> #####abcdefg#####        # 居中

猜你喜欢

转载自www.cnblogs.com/qyh1499816254/p/10623666.html
今日推荐