【发布时间】:2017-06-21 22:08:19
【问题描述】:
#Right now
list(map(lambda x: f1.write(x + ','),feature))
# Would like it to be:
list(map(lambda x: if(x = map.end) f1.write(x) else: f1.write(x),feature))
像上面的示例代码一样,我可以做些什么来排除或产生异常,以便地图的最后一个元素做其他事情
【问题讨论】:
-
使用 enumerate 来跟踪当前索引并与 lambda 表达式中的 len 进行比较