Python3-string-rstrip
提供:Dev Guides
Python 3-ストリングrstrip()メソッド
説明
- rstrip()*メソッドは、文字列の末尾からすべての文字が削除された文字列のコピーを返します(デフォルトの空白文字)。
構文
以下は、* rstrip()*メソッドの構文です-
str.rstrip([chars])
パラメーター
*chars* -トリミングする必要のある文字を指定できます。
戻り値
このメソッドは、すべての文字が文字列の末尾から削除された文字列のコピーを返します(デフォルトの空白文字)。
例
次の例は、rstrip()メソッドの使用法を示しています。
#!/usr/bin/python3
str = " this is string example....wow!!! "
print (str.rstrip())
str = "*****this is string example....wow!!!*****"
print (str.rstrip('*'))
結果
上記のプログラムを実行すると、次の結果が生成されます-
this is string example....wow!!!
*****this is string example....wow!!!