Capitalize a string

前端 未结 9 734
轻奢々
轻奢々 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:45

    Docs can be found here for string functions https://docs.python.org/2.6/library/string.html#string-functions
    Below code capitializes first letter with space as a separtor

    s="gf12 23sadasd"
    print( string.capwords(s, ' ') )
    

    Gf12 23sadasd

提交回复
热议问题