Latest web development tutorials

Python3 capitalize()方法

Python3 字符串 Python3字符串


描述

Python capitalize()將字符串的第一個字母變成大寫,其他字母變小寫。

語法

capitalize()方法語法:

str.capitalize()

參數

  • 無。

返回值

該方法返回一個首字母大寫的字符串。

實例

以下實例展示了capitalize()方法的實例:

#!/usr/bin/python3

str = "this is string example from w3big....wow!!!"

print ("str.capitalize() : ", str.capitalize())

以上實例輸出結果如下:

str.capitalize() :  This is string example from w3big....wow!!!

Python3 字符串 Python3字符串