Python3 swapcase()方法

Python3 字符串 Python3 字符串


描述

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

语法

swapcase()方法语法:

str.swapcase();

参数

  • NA。

返回值

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

实例

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

#!/usr/bin/python3
str = "this is string example....wow!!!"
print (str.swapcase())
str = "This Is String Example....WOW!!!"
print (str.swapcase())

以上实例输出结果如下:

THIS IS STRING EXAMPLE....WOW!!!
tHIS iS sTRING eXAMPLE....wow!!!

Python3 字符串 Python3 字符串

0 个评论

要回复文章请先登录注册