定义函数将字符串首字母大写: 例1:Study hard, improve every day. def toJadenCase(string): return string.title()print(toJadenCase("study hard, improve every day.")) 例2:How can mirrors be real if our eyes aren't real. 第一种:结合capitalize和split: def toJadenCase(strin…
string.capwords() 将每个单词首字母大写 代码: 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. 请按任意键继续. . . string模…