Python lstrip()メソッド
説明
Python lstrip() メソッドは、文字列の左側の空白または指定した文字を除去するために使用します。
構文
lstrip()メソッドの構文:
str.lstrip([chars])
パラメータ
- chars -- 除去する文字を指定します。
戻り値
文字列の左側の空白または指定した文字を除去した後に生成される新しい文字列を返します。
例
以下の例では、lstrip() の使用方法を示しています。
#!/usr/bin/python
str = " this is string example....wow!!! ";
print str.lstrip();
str = "88888888this is string example....wow!!!8888888";
print str.lstrip('8');
上記の例の出力結果は次のとおりです:
this is string example....wow!!! this is string example....wow!!!8888888
その他の拡張
Python 文字列