Python String swapcase() 方法

Python String swapcase() 方法

Python swapcase() 方法用于对字符串的大小写字母进行转换,即将大写字母转换为小写字母,小写字母会转换为大写字母

Python String swapcase() 语法

swapcase() 方法语法:

str.swapcase();

Python String swapcase() 参数

  • NA。

Python String swapcase() 返回值

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

Python String swapcase() 示例1

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

#!/usr/bin/python

str = "APIDEMOS";
print ( str.swapcase() );

str = "apidemos";
print ( str.swapcase() );

str = "abCDE--ApiDemos";
print ( str.swapcase() );

输出:

Python String swapcase() 方法


赞(0)
未经允许不得转载:极客笔记 » Python String swapcase() 方法

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址