0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python split 文字列をリストに

Last updated at Posted at 2018-12-17

文字列を空白やスラッシュなどで切り分けたいときには、split関数を使います。 例えば下記のように英文を空白で区切って単語のリストにすることができます。

切り分けたい文字列
test_sentence = "this is a test sentence."
splitでリストにする
test_sentence.split(" ")
出力結果
["this", "is", "a", "test", "sentence."] 

splitの使い方は

切り分けたい文字列.split("区切る記号", 区切る回数)

となっており、区切る回数を指定することで先頭から何回区切るかを指定することができます。

引用:アイデミーデータクレンジングコース
(弊社の上記サイトでは問題演習が可能です(この講座は有料です))

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?