开发者

Python First Letter of a word Upper CASE [duplicate]

开发者 https://www.devze.com 2023-02-16 21:31 出处:网络
This question already has answers here: 开发者_运维问答 How can I capitalize the first letter of each word in a string?
This question already has answers here: 开发者_运维问答 How can I capitalize the first letter of each word in a string? (23 answers) Closed 9 years ago.

I'm looking for some very clever and fast way of transforming every first character of a word in a string with the upper case.

ac milan > Ac Milan
paris saint germain > Paris Saint Germain


Use the title method of str:

'ac milan'.title()


Is this what you're looking for?

>>> "how now brown cow".title()
'How Now Brown Cow'
0

精彩评论

暂无评论...
验证码 换一张
取 消