龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > python编程 >

跟老齐学Python之玩转字符串(2)(2)

时间:2014-09-15 02:46来源:网络整理 作者:网络 点击:
分享到:
看例子: 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

字符串问题,看来本讲还不能结束。下一讲继续。有看官可能要问了,上面这些在实战中怎么用?我正想为你的,请键客设计一种实战情景,能不能用上所学。

精彩图集

赞助商链接