2. 这里我们举例说明各自的用途:
#大小写转换
str3 = "Hello"
str4 = "WORLD"
str5 = "shirley.xie"
str6 = "welcome to here"
print(str3.upper()) #转化所有为大写
print(str4.lower()) #转换所有为小写
print("shirley.xie".title()) #转换每个单词首字母为大写
print("welcome to here".capitalize()) #转换第一个首字母大写
输出的结果为:
HELLO
world
Shirley.Xie
Welcome to here
n=ord(input("input an english letter: "))if 65<=n<=90:
print('大写字符')
elif 97<=n<=122:
print('小写字符')
else:
print('其他字符')