如果不使用这个函数,需要把字符串使用split()函数进行分割成列表,最后依次对每个单词的首字母变成大写,再使用join()函数来组合出来。
输出如下:五子棋游戏开发
http://edu.csdn.net/course/detail/5487
使用这个函数就更简单:
import string
s = '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.