Latest web development tutorials

Python conversão caso cadeia

Document Object Reference Exemplos Python3

O código a seguir demonstra como converter uma string para maiúsculas ou minúsculas, e assim a string:

# Filename : test.py
# author by : www.w3big.com

str = "www.w3big.com"
print(str.upper())          # 把所有字符中的小写字母转换成大写字母
print(str.lower())          # 把所有字符中的大写字母转换成小写字母
print(str.capitalize())     # 把第一个字母转化为大写字母,其余小写
print(str.title())          # 把每个单词的第一个字母转化为大写,其余小写 

Executar os resultados de saída do código acima:

WWW.w3big.com
www.w3big.com
Www.w3big.com
Www.w3big.com

Document Object Reference Exemplos Python3