Python文字列strip
lower

strip文字列

lstrip

先頭と末尾の空白(または指定した文字)を除去します。

構文

str.strip(chars?)

使用例

下記の値を入力するとサンプルに即時反映されます。

print
strip
text = "  hello world  "
print(text.strip())   # "hello world"
print("***hi***".strip("*"))  # "hi"