摘要:
方法1:defgcd(x, y):whilen: x, y=y, x%yreturnx方法2:def yue(x,y): if y: return gcd(y,x%y) else: return x 阅读全文
摘要:
列表推导式(list comprehension)是利用其他列表创建新列表(类似于数学术语中的集合推导式)的一种方法。它的工作方式类似于for循环,也很简单:In [39]: [x*x for x in range(10)]Out[39]: [0, 1, 4, 9, 16, 25, 36, 49, ... 阅读全文