0
0

リストをカンマ区切りの文字列にしたい

Posted at

使うたびに調べているので、自分用のメモとして記します。

やりたいこと

リストをカンマ区切りの文字列にしたい

具体例

todofuken = ["北海道", "青森", "秋田", ....,"沖縄"]

上記のtodofukenリストを北海道,青森,秋田,....,沖縄という文字列にしたい。

やり方

コード

todofuken = ["北海道", "青森", "秋田", ....,"沖縄"]

# カンマ区切りで結合
text = ','.join(todofuken)
print(text) 

実行結果

北海道,青森,秋田,....,沖縄
0
0
0

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