跟老齐学Python之玩转字符串(2)(2)
看例子: a = "Hello,World" a.upper() #都是大写'HELLO,WORLD' a.lower() #都是小写'hello,world' a.capitalize() #首字母大写,其余小写'Hello,wold' a.istitle() #首字母是否是大写,
看例子:
>>> a = "Hello,World" >>> a.upper() #都是大写 'HELLO,WORLD' >>> a.lower() #都是小写 'hello,world' >>> a.capitalize() #首字母大写,其余小写 'Hello,wold' >>> a.istitle() #首字母是否是大写,如果是返回True,不是返回False True >>> a 'Hello,Wold' >>> b="hellow,world" >>> b.istitle() #首字母不是大写,返回false False >>> a.islower() #是否字符串中都是小写,如果是返回true,不是返回false False >>> b.islower() True
字符串问题,看来本讲还不能结束。下一讲继续。有看官可能要问了,上面这些在实战中怎么用?我正想为你的,请键客设计一种实战情景,能不能用上所学。
收藏文章
精彩图集
精彩文章