Discuss / Python / takewhile在实际中应用是起到什么作用呢?

takewhile在实际中应用是起到什么作用呢?

Topic source
sum([4/(2*x-1)*(-1)**(x-1) for x in itertools.takewhile(lambda x: x <= 100, itertools.count(1))])

其实itertools.takewhile(lambda x: x <= 100, itertools.count(1))生成的序列和range(1, 101)没啥区别


  • 1

Reply