Fork me on GitHub

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!!!
posted @ 2017-10-18 16:22  IT技术随笔  阅读(4032)  评论(0编辑  收藏  举报
返回顶部↑