正在打印语句“Hello before using list(zip_shop)”。
语句“您好,使用 list(zip_shop)”后没有打印出来。
groceries = ["apple","chips","bread","icecream"]
price = [2,3,1.2,4.25]
print("groceries = ",groceries,"and price =",price)
zip_shop = zip(groceries,price)
print("zip_shop =", zip_shop,"and type(zip_shop) =",type(zip_shop),"and id(zip_shop) = ",id(zip_shop))
for g, p in zip_shop:
print("Hello before using list(zip_shop)")
print("list(zip_shop)=", list(zip_shop),"and type(zip_shop) =",type(zip_shop),"and id(zip_shop) = ",id(zip_shop))
for g, p in zip_shop:
print("Hello after using list(zip_shop)")
有人可以帮我理解这里的行为吗?
输出如下:
groceries = ['apple', 'chips', 'bread', 'icecream'] and price = [2, 3, 1.2, 4.25]
zip_shop = <zip object at 0x0000022852A29948> and type(zip_shop) = <class 'zip'> and id(zip_shop) = 2372208335176
Hello before using list(zip_shop)
Hello before using list(zip_shop)
Hello before using list(zip_shop)
Hello before using list(zip_shop)
list(zip_shop)= [] and type(zip_shop) = <class 'zip'> and id(zip_shop) = 2372208335176
Process finished with exit code 0
开满天机
郎朗坤
相关分类