Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Python | map関数でシーケンスを操作

概要

map関数でシーケンスを操作

内容

シーケンスのそれぞれの要素に対して一定の操作をする場合に
map関数を利用します。

サンプルコード

# -*- coding: utf-8 -*-
words = "1,2,3,4".split(",")
words = map(lambda x: x + "times", words)
print words

出力

['1times', '2times', '3times', '4times']