Describe
Python capitalize () capitalizes the first letter of a string and other letters to lowercase.
Grammar
Capitalize () method syntax:
return value
The method returns a first-letter uppercase string.
Cases
#!/usr/bin/env python#-*-coding:utf-8-*-#Author:az Ning" "Note that: 1. The first character is converted to uppercase, and the remaining characters are converted to lowercase. 2, if the first character is non-letter, the initial letter will not be converted to uppercase, will be converted to lowercase. " "Str="Abcdefghigk"str_1= Str.capitalize ()#capitalize the first digit of the string as a letterPrint(str_1) str_2="89FAFASAAAAAAASDFSF" #if the first non-letter, the first position does not make any changes, all subsequent uppercase letters become lowercaseStr_2 =str_2.capitalize ()Print(str_2)
The results of the operation are as follows:
Abcdefghigk89fafasaaaaaaasdfsf
The capitalize of the string method