python string case

python string case

str = "love python"
print(str.capitalize())   #把字符串的第一个字母大写
print(str.title())        #把字符串中的单词首字母大写
print(str.upper())        #把字符串中的所有字母大写
print(str.lower())        #把字符串的所有字母小写
------------------------
Love python
Love Python
LOVE PYTHON
love python

to sum up

method effect
capitalize() The first letter capitalized
title() All capitalized words
upper() All capital letters
lower() All lowercase letters

Guess you like

Origin www.cnblogs.com/yuelu/p/11954591.html