logo
  • 教程列表
  • SO官方文檔
  • Functools 模組
    • 區域性
    • lru 快取
    • cmp to key
    • 總訂貨量
    • 降低
  1. StackOverflow 文件
  2. Python Language 教程
  3. Functools 模組
  4. 降低

降低

Created: November-22, 2018

在 Python 3.x 中,已在此處解釋的 reduce 函式已從內建函式中刪除,現在必須從 functools 匯入。

from functools import reduce
def factorial(n):
    return reduce(lambda a, b: (a*b), range(1, n+1))
  • 總訂貨量

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明