python的一些好的非主流语法用法,python非主流语法,#编程新手def fac


#编程新手def factorial(x):      if x == 0:          return 1     else:          return x * factorial(x - 1)  print factorial(6) #懒惰的Python程序员def fact(x):      return x > 1 and x * fact(x - 1) or 1 print fact(6) #更懒的Python程序员f = lambda x: x and x * f(x - 1) or 1 print f(6) #Python 专家fact = lambda x: reduce(int.__mul__, xrange(2, x + 1), 1)  print fact(6) #Python 黑客import sys  @tailcalldef fact(x, acc=1):      if x: return fact(x.__sub__(1), acc.__mul__(x))      return acc  sys.stdout.write(str(fact(6)) + '\\n') #专家级程序员from c_math import fact  print fact(6) #大英帝国程序员from c_maths import fact  print fact(6)#该片段来自于http://byrx.net

评论关闭