Python 高階函數 傳入參數是函數

      網友投稿 851 2022-05-30

      環境信息

      ModelArts

      Notebook - pytorch1.4-cuda10.1-cudnn7-ubuntu18.04

      JupyterLab - Notebook - Conda-python3

      Python 高階函數 傳入參數是函數

      高階函數 傳入參數是函數

      def add(num1,num2,fun): return fun(num1)+fun(num2)

      add(-1,1,abs) 2

      add

      abs

      my_list = [1,3,5,7] # my_list不變,用fun去處理iterables的每一個元素,并返回一個新的map對象 result = map(lambda x:x*x,my_list) list(result)

      from functools import reduce my_list = [1,3,5,7] # reduce簡介: fun(fun(fun(x1,x2),x3),x4) result = reduce(lambda x,y:x*10+y,my_list) result 1357

      help

      help(abs) Help on built-in function abs in module builtins: abs(x, /) Return the absolute value of the argument.

      help(map) Help on class map in module builtins: class map(object) | map(func, *iterables) --> map object | | Make an iterator that computes the function using arguments from | each of the iterables. Stops when the shortest iterable is exhausted. | | Methods defined here: ......

      help(reduce) Help on built-in function reduce in module _functools: reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.

      相關鏈接

      Python入門篇

      Python進階篇

      Python應用篇

      幫助文檔-AI開發平臺ModelArts

      【生長吧!Python】有獎征文火熱進行中

      備注

      歡迎各位同學一起來交流學習心得^_^

      在線課程、沙箱實驗、認證、論壇和直播,其中包含了許多優質的內容,推薦了解與學習。

      AI開發平臺ModelArts Python

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      上一篇:爬蟲管理平臺 Crawlab v0.4.8 發布
      下一篇:西南科技大學城市學院-城南校區同款FPS地圖by楊曉宇
      相關文章
      亚洲啪啪免费视频| 中文字幕在亚洲第一在线| 国产av天堂亚洲国产av天堂 | 色五月五月丁香亚洲综合网| 亚洲精品成人网站在线播放| 黑人精品videos亚洲人| 亚洲人成无码网WWW| 亚洲AV无码一区二区三区国产| 亚洲精品国产精品| 亚洲综合无码无在线观看| 亚洲中文无码线在线观看| 亚洲国产精品久久丫| 亚洲伊人久久大香线蕉啊| 亚洲一区二区三区高清视频| 亚洲一区中文字幕在线电影网| 精品久久久久久亚洲精品| 亚洲人成电影网站| 亚洲偷自精品三十六区| 国产精品高清视亚洲一区二区| 亚洲日本一线产区和二线产区对比| 亚洲日韩精品无码专区加勒比☆| 亚洲另类无码一区二区三区| 亚洲AV无码男人的天堂| 午夜亚洲国产精品福利| 亚洲国产成人久久精品99| 亚洲人成人无码网www国产| 自拍偷自拍亚洲精品情侣| 亚洲精品无码AV人在线播放| 亚洲av永久无码精品漫画| 亚洲综合日韩中文字幕v在线| 亚洲综合在线成人一区| 亚洲人成人77777在线播放| 亚洲无吗在线视频| 豆国产96在线|亚洲| 亚洲日本一区二区一本一道| 亚洲精品自在在线观看| 夜夜亚洲天天久久| 99久久婷婷国产综合亚洲| 亚洲AV无码专区在线电影成人| 亚洲成av人在片观看| 亚洲精品无码永久在线观看你懂的|