string模块的capwords()函数会把一个字符串中的所有单词首字母大写。
import strings = 'The quick brown fox jumped over the lazy dog.'print(s)print(string.capwords(s))
输出结果:
The quick brown fox jumped over the lazy dog.The Quick Brown Fox Jumped Over The Lazy Dog.