from functools import reduce from operator import mul def fact(n): #使用reduce和operator.mul函数计算阶乘 return reduce(mul, range(1, n+1)) #使用reduce函数和一个匿名函数计算阶乘 # return reduce(lambda a, b:a*b, range(1,n+1))
标签:return,函数,reduce,operator,阶乘,mul From: https://www.cnblogs.com/bravesunforever/p/17338185.html