当前位置 :
pythonmap和reduce的用法
 更新时间:2024-04-27 14:28:46
1人问答
问题描述:

pythonmap和reduce的用法

饶伏波回答:
  map(function,sequence[,sequence,...])->list   Returnalistoftheresultsofapplyingthefunctiontotheitemsof   theargumentsequence(s).Ifmorethanonesequenceisgiven,the   functioniscalledwithanargumentlistconsistingofthecorresponding   itemofeachsequence,substitutingNoneformissingvalueswhennotall   sequenceshavethesamelength.IfthefunctionisNone,returnalistof   theitemsofthesequence(oralistoftuplesifmorethanonesequence).   reduce(...)   reduce(function,sequence[,initial])->value   Applyafunctionoftwoargumentscumulativelytotheitemsofasequence,   fromlefttoright,soastoreducethesequencetoasinglevalue.   Forexample,reduce(lambdax,y:x+y,[1,2,3,4,5])calculates   ((((1+2)+3)+4)+5).Ifinitialispresent,itisplacedbeforetheitems   ofthesequenceinthecalculation,andservesasadefaultwhenthe   sequenceisempty.
最新更新
查询网(025773.com)汇总了汉语字典,新华字典,成语字典,组词,词语,在线查字典,中文字典,英汉字典,在线字典,康熙字典等等,是学生查询学习资料的好帮手,是老师教学的好助手。
声明:本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。

邮箱:  联系方式:

Copyright©2009-2021 查询网 025773.com 版权所有 闽ICP备18026954号-20