【发布时间】:2015-05-12 14:14:42
【问题描述】:
假设我有元素列表 content = ['121\n', '12\n', '2\n', '322\n'] 和函数列表 fnl = [str.strip, int]。
所以我需要将fnl 中的每个函数依次应用于content 中的每个元素。
我可以通过几个电话map 来做到这一点。
另一种方式:
xl = lambda func, content: map(func, content)
for func in fnl:
content = xl(func, content)
我只是想知道是否有更 Pythonic 的方式来做到这一点。
没有单独的功能?通过单个表达式?
【问题讨论】:
标签: python python-2.7 lambda