Python 字符串 capitalize() 方法

實例

大寫這句話的第一個字母:

txt = "hello, and welcome to my world."
x = txt.capitalize()
print (x)

運行實例

定義和用法

capitalize() 方法返回一個字符串,其中第一個字符為大寫。

語法

string.capitalize()

參數值

無參數

更多實例

實例

請看第一個字符是數字時會發生什么:

txt = "63 is my age."
x = txt.capitalize()
print (x)

運行實例