Python swapcase()メソッド

Python 字符串Python 文字列


説明

Python swapcase()このメソッドは、文字列の大文字と小文字を変換するために使用され、つまり、大文字は小文字に変換され、小文字は大文字に変換されます。。

構文

swapcase()メソッドの構文:

str.swapcase();

パラメータ

  • NA。

戻り値

大文字・小文字を変換した新しい文字列を返します。

例

以下の例では、swapcase() 関数の使用方法を示しています。

例

#!/usr/bin/python str = "サンプル!!!"; print ( str.swapcase() ); str = "サンプル!!!"; print ( str.swapcase() ); str = "abCDE--example!!!"; print ( str.swapcase() );

上記の例の出力結果は次のとおりです。

サンプル!!!
サンプル!!!
ABcde--example!!!

Python 字符串Python 文字列

その他の拡張