区切り文字で分割: split() 区切り文字で分割するには文字列(str型)のsplit()メソッドを使う。 組み込み型 - str.split() — Python 3.11.4 ドキュメント デフォルトは空白文字(スペースや改行\n、タブ\tなど)で分割する。連続する空白文字はまとめて処理される。 戻り値はリスト。 s_blank = 'one two three\nfour\tfive' print(s_blank) # one two three # four five print(s_blank.split()) # ['one', 'two', 'three', 'four', 'five'] print(type(s_blank.split())) # <class 'list'>
![Pythonで文字列を分割(区切り文字、改行、正規表現、文字数) | note.nkmk.me](https://cdn-ak-scissors.b.st-hatena.com/image/square/7fecc8e3f0665d3686ba2411a11632b7ac1dfc32/height=288;version=1;width=512/https%3A%2F%2Fi.gyazo.com%2F3897c3eabad904c5f194d15b8345dfaf.png)