列表循环式:[x * x for x in range(1, 11)]
生成器:(x * x for x in range(1, 11))后者返回一个对象:
>>> L = [x*x for x in range(10)] >>> L [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] >>> g = (x*x for x in range(10)) >>> g <generator object <genexpr> at 0x0000028F8B774200>