码迷,mamicode.com
首页 > 其他好文 > 详细

字符串 - 大写

时间:2019-03-17 01:04:26      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:ora   nbsp   tle   mil   ali   bsp   font   span   lin   

全字符

str.upper()

eg,

s = ‘ash‘

s.upper()

print(s) #ash

print(s.upper()) #ASH

str.lower()

 

首字母

首字母大写

str.capitalize()

一般情况

首字母若为空/数字

eg,

s = ‘a, b‘

s2 = ‘ a, b‘

s3 = ‘1, a, b‘

print(s.capitalize()) #A, b

print(s2.capitalize()) # [_]a, b

print(s3.capitalize()) #1, a, b

字符串中单词的首字母大写

str.title()

eg,

s = ‘ash, ruby‘

print(s.title()) #Ash, Ruby

字符串 - 大写

标签:ora   nbsp   tle   mil   ali   bsp   font   span   lin   

原文地址:https://www.cnblogs.com/norasgao/p/10545010.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!