目录
- swapcase的功能
- swapcase的用法
- swapcase 的注意事项
swapcase的功能
- 将字符串中大小写字母进行转换(将大写转为小写,将小写转为大写)
swapcase的用法
- 用法:
newstr = string.swapcase()
- 参数:函数括弧内什么都不用填写
In [11]: name = 'Insane'
In [12]: new_name = name.swapcase()
In [13]: print(new name)
iNSANE
swapcase的注意事项
number_message = '1@oK' -> '1@Ok'
info = ' python语言很有趣! ' -> 'PYTHON语言很有趣!'
实战
info_one = 'Python Code Is Good'
info_two = 'PYTHON DJANGO FLASK'
info_three = 'python web so easy'
print(info_one.swapcase())
print(info_two.swapcase())
print(info_three.swapcase())
pYTHON cODE iS gOOD
python django flask
PYTHON WEB SO EASY
Process finished with exit code 0