How can I capitalize the first letter of each word in a string?

前端 未结 19 2284
深忆病人
深忆病人 2020-11-22 17:17
s = \'the brown fox\'

...do something here...

s should be:

\'The Brown Fox\'

What\'s the easiest

19条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 17:24

    Easiest solution for your question, it worked in my case:

    import string
    def solve(s):
        return string.capwords(s,' ') 
        
    s=input()
    res=solve(s)
    print(res)
    

提交回复
热议问题