Python swapcase() 方法

描述

Python swapcase() 方法用于对字符串的大小写字母进行转换。

语法

swapcase() 方法语法:

S.swapcase()

参数

  • 无。

返回值

返回大小写字母转换后生成的新字符串。

实例

以下实例展示了 swapcase() 方法的使用方法:

#!/usr/bin/python3

S = "this is string example....wow!!!"
print (S.swapcase())

S = "This Is String Example....WOW!!!"
print (S.swapcase())

以上实例输出结果如下:

THIS IS STRING EXAMPLE....WOW!!!
tHIS iS sTRING eXAMPLE....wow!!!
原文地址:https://www.cnblogs.com/wushuaishuai/p/7687331.html