Fork me on GitHub

青禹小生

雁驰万里却作禽,鱼未得水空有鳞。 花开花落花不语,昨是昨非昨亦今。

导航

给定一个英文句子(一个只有字母的字符串),将句中所有单词变为有且只有首字母大写

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

posted on 2016-11-22 21:42  司徒道  阅读(1171)  评论(0编辑  收藏  举报