马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 ssss1111 于 2020-3-28 11:54 编辑
capitalize ()只能使第一句首字母大写,不能对全段起作用
目的
一段话有三句话,使三句话的首字母都变成大写(不是让每个单词首字母变大写)。
问题
使用capitalize(),只能使第一句首字母变成大写。我的版本是Python 3.7.3。是我的版本问题,还是确实如此?
代码如下:"she likes it. it's cute. they play together.".capitalize()
结果如下:
"She likes it. it's cute. they play together."
只有第一句变大写了,后面两句没有变。
>>> print(". ".join([each.capitalize() for each in "she likes it. it's cute. they play together.".split(". ")]))
She likes it. It's cute. They play together.
|