python 英文字串首字母改为大写

#英文字串首字母改为大写
st = "string"
St = st[0].upper() + st[1:]

 

2016-10-22

后来了解到 python 内部有相关实现,感觉 python 好贴心~~~

>>> "hehe he hehe".capitalize()
'Hehe he hehe'

>>> "hehe he hehe".title()
'Hehe He Hehe'

  

posted @ 2016-05-01 21:17  LandFlow  阅读(2050)  评论(0编辑  收藏  举报