python的一些好的非主流语法用法,python非主流语法,#编程新手def fac
文章由Byrx.net分享于2019-03-23 08:03:46
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 @tailcall def 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)
相关内容
- Learn Python By Practice — Range和Slice扩展学习,pythonslice,
- HTMLParser笔记,,[Python]代码#-
- Learn Python By Practice — 文件读写,,import sysim
- Learn Python By Practice — dict,pythondict,def dictTest
- Learn Python By Practice — list,pythonpractice,import sysde
- Learn Python By Practice — string,pythonpractice,import sys#
- 定时关机神器,定时关机神,[Python]代码im
- 文本搜索 矩阵重建,文本矩阵重建,简述:一个含有如
- 一个简单的二叉树实现,简单二叉树实现,[Python]代码
- Python unicode码转utf8,pythonutf8,[Python]代码de
评论关闭