久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

首次使用后 zip 變量為空

zip variable empty after first use(首次使用后 zip 變量為空)
本文介紹了首次使用后 zip 變量為空的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

Python 3.2

t = (1, 2, 3)
t2 = (5, 6, 7)
z = zip(t, t2)

for x in z:
    print(x)

結(jié)果:

(1, 5)
(2, 6)
(3, 7)

之后立即放入完全相同的循環(huán),什么都不會(huì)打印:

Putting in EXACTLY the same loop immediately after, nothing is printed:

for x in z:
    print(x)

z 仍然作為 <zip 對(duì)象存在于 0xa8d48ec>.我什至可以重新分配 tt2 以再次壓縮,但它只能工作一次,而且只能工作一次.

z still exists as <zip object at 0xa8d48ec>. I can even reassign the t, t2 to be zipped again, but then it only works once and only once, again.

這是它應(yīng)該如何工作的嗎?文檔中沒(méi)有提及這一點(diǎn).

Is this how its supposed to work? There's no mention in the docs about this.

推薦答案

這就是它在 python 3.x 中的工作方式.在 python2.x 中,zip 返回一個(gè)元組列表,但對(duì)于 python3.x,zip 的行為類似于 itertools.izip 在 python2.x 中的行為.要恢復(fù) python2.x 的行為,只需從 zip 的輸出中構(gòu)造一個(gè)列表:

That's how it works in python 3.x. In python2.x, zip returned a list of tuples, but for python3.x, zip behaves like itertools.izip behaved in python2.x. To regain the python2.x behavior, just construct a list from zip's output:

z = list(zip(t,t2))

請(qǐng)注意,在 python3.x 中,許多內(nèi)置函數(shù)現(xiàn)在返回迭代器而不是列表(mapzipfilter)

Note that in python3.x, a lot of the builtin functions now return iterators rather than lists (map, zip, filter)

這篇關(guān)于首次使用后 zip 變量為空的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周圍繪制一個(gè)矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測(cè)和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個(gè)矩形邊界框中應(yīng)用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據(jù)文本方向檢測(cè)圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測(cè)圖像中矩形的中心和角度)
主站蜘蛛池模板: 久久久精品综合 | 91免费观看在线 | 久久国产一区二区三区 | 中文字幕亚洲欧美日韩在线不卡 | 欧美a在线观看 | 毛片网站在线观看视频 | 成人在线免费电影 | 在线伊人 | 久久精品一级 | 亚洲天堂中文字幕 | a a毛片 | 久久久亚洲成人 | 国产黄色av网站 | 免费观看a级毛片在线播放 黄网站免费入口 | 亚洲精品在线免费观看视频 | 国产精品视频偷伦精品视频 | 亚洲超碰在线观看 | 国产精品123区 | 精品视频在线观看 | 亚洲视频免费观看 | 亚洲成人一区二区 | a级大片免费观看 | 亚洲成在线观看 | 中文字幕一区二区视频 | 国产成人精品午夜 | 亚洲精品视频在线 | 精品视频一区二区三区在线观看 | 午夜欧美a级理论片915影院 | 久久久久久高潮国产精品视 | 超碰国产在线 | 热99在线| 精品一二区 | 人人看人人爽 | 精品国产免费一区二区三区五区 | 国产区在线免费观看 | av黄色在线 | 99re在线视频 | 逼逼网 | 欧美成年人视频在线观看 | 国产乱码精品1区2区3区 | 久久久毛片 |