怎么把字符串转换成小写或大写等等

#使用lower方法把字符串转换为小写
a='Ayushi'.lower()
print(a)#ayushi

#使用upper方法把字符串转换为大写
b='Ayushi'.upper()
print(b)#AYUSHI

# 使用isupper()和islower()方法检查字符串是否全为大写或小写
print('Ayushi'.isupper())#False
print('AYUSHI'.isupper())#True
print('ayushi'.islower())#True

#@和$这样的字符既满足大写也满足小写
print('@yu$hi'.islower())#True
print('@YU$HI'.isupper())#True

print('The Corpse Bride'.istitle())#判断一个字符串是否为标题格式

猜你喜欢

转载自www.cnblogs.com/z-x-y/p/9907265.html