Latest web development tutorials

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!!!

Python 字符串 Python字符串