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文字列