Python3 swapcase()方法
描述
swapcase() 方法用於對字串的大小寫字母進行轉換。
語法
swapcase()方法語法:
str.swapcase();
參數
- NA。
返回值
返回大小寫字母轉換後生成的新字串。
實例
以下實例展示了swapcase()函數的使用方法:
#!/usr/bin/python3 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!!!