Python把所有东西写成一行,性能会更好吗?可读性会更强吗?
By
lincanbin
at 2015-12-08 • 0人收藏 • 1591人看过
当然不会。
2 个回复 | 最后更新于 2015-12-08
回复#1 @icefairy :
这里是说lambda之类的东西。
# -*- coding: utf-8 -*- import string, random g = lambda a, b : "".join(random.sample(string.letters, a)) + "".join(random.sample(string.digits, b))
或者是这样:
# -*- coding: utf-8 -*- print(len([1 for a in [x+y for x,y in [(k,j) for k in [i**3 for i in xrange(int(round(pow(100000, 1./3))))] for j in [i**3 for i in xrange(int(round(pow(100000, 1./3))))] if k <= j]] if [x+y for x,y in [(k,j) for k in [i**3 for i in xrange(int(round(pow(100000, 1./3))))] for j in [i**3 for i in xrange(int(round(pow(100000, 1./3))))] if k <= j]].count(a)==2])/2)
双倍超立方数计算
登录后方可回帖
不会报错?py不让那么写的吧