Python 字符串 capitalize() 方法
定义和用法
capitalize() 方法返回一个字符串,其中第一个字符为大写。
实例
例子 1
大写这句话的第一个字母:
txt = "hello, and welcome to my world." x = txt.capitalize() print (x)
例子 2
请看第一个字符是数字时会发生什么:
txt = "63 is my age." x = txt.capitalize() print (x)
语法
string.capitalize()
参数值
无参数。