Python swapcase()方法

Python 字串 Python 字串


描述

Python swapcase() 方法用於對字串的大小寫字母進行轉換。

語法

swapcase()方法語法:

str.swapcase();

參數

  • NA。

返回值

返回大小寫字母轉換後生成的新字串。

實例

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

實例

#!/usr/bin/python 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!!!

Python 字串 Python 字串