まず結論

.strip().split() は、文字列に対する操作です。

text = "  apple,banana  "
print(text.strip())

.strip() は、前後の空白を取り除きます。

こんなときに読む記事です

次のようなところで止まった人向けです。

  • text.strip() のドットが読めない
  • .split() が何を返しているのか分からない
  • メソッドという言葉が分からない

最初は「ドットの後ろは、その値に対する操作」と考えれば十分です。

stripは前後の空白を取る

strip() は、文字列の前後にある空白や改行を取り除きます。

text = "  hello  "
clean = text.strip()
print(clean)

結果は "hello" です。

splitは分ける

split() は、文字列を分けてリストにします。

text = "apple,banana,orange"
items = text.split(",")
print(items)

結果は ["apple", "banana", "orange"] です。

replaceは置き換える

replace() は、文字列の一部を置き換えます。

text = "hello"
new_text = text.replace("h", "H")
print(new_text)

結果は "Hello" です。

元の文字列は変わらない

文字列のメソッドは、新しい文字列を返すことが多いです。

text = "  hello  "
text.strip()
print(text)

この場合、text 自体は元のままです。
結果を使いたいなら、変数に入れます。

text = text.strip()

読み方のコツ

text.strip() は「text に対して strip する」と読みます。
ドットが出てきたら、「左側の値の機能を使っている」と見ると理解しやすいです。