「python入門」strip()、lstirp()とrstirp()の使い方

1.strip()–先頭および末尾から「空白」と「改行」を削除
tt = " Hello World\n".strip()
print tt
結果
'Hello World’

2.lstirp()–文字列の先頭から任意の文字列を削除
tt = " Hello World\n".lstrip()
print tt
結果
'Hello World\n’

3.rstirp()--文字列の末尾から文字列を削除
tt = " Hello World\n".rstrip()
print tt
結果
' Hello World’

Python

Posted by arkgame