map函數

一,例: 二,可以定義多個函數 print(map_test(add,num))可以用匿名函數代替: print(map_test(lambda x:x+1,num)) 使用這條語句則不需要定義add函數。 注:上述兩個代碼中的for i in num 這裏的num應改爲 array 或者:(使用內置map函數,匿名函數): res=map(lambda x:x+1,num) print(‘內置函
相關文章
相關標籤/搜索