Python 的 str.swapcase() 方法将提供的字符串的所有小写字符转换为大写,并将所有大写字符转换为小写。
参数
无参数。
返回值
返回一个字符串,其中源字符串的所有小写字符都转换为大写,并且所有大写字符都转换为小写。
例子
要将 "Hello World!" 的所有小写字符转换为大写,并将所有大写字符转换为小写:
x = "Hello World!"
x.swapcase()
hELLO wORLD!
hELLO wORLD!
相关用法
- Python String swapcase()用法及代码示例
 - Python String startswith()用法及代码示例
 - Python String splitlines()用法及代码示例
 - Python String split方法用法及代码示例
 - Python String splitlines方法用法及代码示例
 - Python String strip方法用法及代码示例
 - Python String split()用法及代码示例
 - Python String strip()用法及代码示例
 - Python String startswith方法用法及代码示例
 - Python String count方法用法及代码示例
 - Python String isnumeric方法用法及代码示例
 - Python String Center()用法及代码示例
 - Python String zfill方法用法及代码示例
 - Python String rstrip方法用法及代码示例
 - Python String decode()用法及代码示例
 - Python String count()用法及代码示例
 - Python String join()用法及代码示例
 - Python String casefold()用法及代码示例
 - Python String isalnum()用法及代码示例
 - Python String endswith方法用法及代码示例
 - Python String rsplit()用法及代码示例
 - Python String isidentifier()用法及代码示例
 - Python String rjust方法用法及代码示例
 - Python String rpartition()用法及代码示例
 - Python String rpartition方法用法及代码示例
 
注:本文由纯净天空筛选整理自Isshin Inada大神的英文原创作品 Python String | swapcase method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
