Python文字列split
rstrip

split文字列

join

区切り文字で分割してリストを返します。

構文

str.split(sep?, maxsplit?)

使用例

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

csv
fruits
split
print
sentence
csv = "apple,banana,cherry"
fruits = csv.split(",")
print(fruits)  # ['apple', 'banana', 'cherry']

sentence = "one two three"
print(sentence.split())  # ['one', 'two', 'three']