Capitalize a string

前端 未结 9 820
轻奢々
轻奢々 2020-11-27 19:33

Does anyone know of a really simple way of capitalizing just the first letter of a string, regardless of the capitalization of the rest of the string?

For example:

9条回答
  •  被撕碎了的回忆
    2020-11-27 19:47

    You can use the str.capitalize() function to do that

    In [1]: x = "hello"
    
    In [2]: x.capitalize()
    Out[2]: 'Hello'
    

    Hope it helps.

提交回复
热议问题