给定一个英文句子(一个只有字母的字符串),将句中所有单词变为有且只有首字母大写
def cap_string1(sentence):
sentence=' '.join([i.capitalize() for i in sentence.split()])
return sentence
def cap_string2(sentence): return sentence.title()
s='''Python is a programming language that lets you work quickly and integrate systems more effectively''' print cap_string1(s)
print cap_string2(s)
输出:
Python Is A Programming Language That Lets You Work Quickly And Integrate Systems More Effectively