Python 的世界里没有代码块

以前经常写 ruby 和 js, 对于以下的代码非常习惯: item = {id: 1, name: 'Donald Clinton'} attrs = [:id, :name] attr_getters = attrs.map do |attr| lambda do "The #{attr} is #{item[attr]}" end end > attr_getters[0][] "The id is 1" > attr_getters[1][] "The name is Donald Clinton" var item = {id: 1,…

Read More