27
20

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.

数値が入ったリストの文字列変換

Posted at

各要素の文字列への変換

リストに数値がいくつか入っているとき、それらを全て文字列に変換するにはmapを使う。

>>>list = [0,1,2,3,4,5]
>>>map(str,list)
['0', '1', '2', '3', '4', '5']

また、これらの要素を","などで区切って一つの文字列にしたい時も一行で書ける。

>>>','.join(map(str,list))
'0,1,2,3,4,5'

センサなどで計測したデータを送信したりするときに便利。

27
20
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
27
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?