Capitalize a string

前端 未结 9 807
轻奢々
轻奢々 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 20:05

    this actually gives you a capitalized word, instead of just capitalizing the first letter

    cApItAlIzE -> Capitalize

    def capitalize(str): 
        return str[:1].upper() + str[1:].lower().......
    

提交回复
热议问题