使用 python3.6.5
>>> test = map(lambda x:x ,range(2))
>>> test
<map object at 0x7f423167bf98>
>>> print(tuple(test))
(0, 1)
>>> print(tuple(test))
()
>>> print(tuple(test))
()
第一 print 之后,值就被销毁了
在 python2.7 下
>>> test = map(lambda x:x ,range(2))
>>> print tuple(test)
(0, 1)
>>> print tuple(test)
(0, 1)
>>> print tuple(test)
(0, 1)
>>>
print 的之后值也一直存在
python3 这是神码特性,难道是 bug??没理由在我 print 之后就销毁值啊,我还要用啊。。。
>>> test = map(lambda x:x ,range(2))
>>> test
<map object at 0x7f423167bf98>
>>> print(tuple(test))
(0, 1)
>>> print(tuple(test))
()
>>> print(tuple(test))
()
第一 print 之后,值就被销毁了
在 python2.7 下
>>> test = map(lambda x:x ,range(2))
>>> print tuple(test)
(0, 1)
>>> print tuple(test)
(0, 1)
>>> print tuple(test)
(0, 1)
>>>
print 的之后值也一直存在
python3 这是神码特性,难道是 bug??没理由在我 print 之后就销毁值啊,我还要用啊。。。