python3 rstrip()メソッド
説明
文字列の指定した文字列の末尾を削除するrstrip()(デフォルトはスペースです)。
文法
rstrip()メソッドの構文:
str.rstrip([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!!!