【String】capwords() 函数 会把字符串中的所有单词首字母大写

import string
s = 'the quick brown fox jumped over the lazy dog.'
print(string.capwords(s))  # 函数 capwords() 会把一个字符串中的所有单词首字母大写
输出结果: The Quick Brown Fox Jumped Over The Lazy Dog.
这个代码的结果等同于先调用 split() ,把结果列表中的单词首字母大写,然后调用join() 来合并结果
posted @ 2021-02-21 14:34  旧时光里的小鱼儿  阅读(124)  评论(0编辑  收藏  举报