Python3 capitalize() Method

Python3 字符串Python3 Strings


Description

Python capitalize() changes the first letter of the string to uppercase and the other letters to lowercase.

Syntax

Syntax of the capitalize() method:

str.capitalize()

Parameters

  • None.

Return Value

This method returns a string with the first letter capitalized.

Example

The following example demonstrates the use of the capitalize() method:

Example

#!/usr/bin/python3

str = "this is string Example From Example....wow!!!"

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

The output of the above example is:

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

Python3 字符串Python3 Strings

Other Extensions