Python-string-lstrip
提供:Dev Guides
Python String 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