我如何在Jupyter笔记本中显示压缩的内容?

问题描述 投票:0回答:1

[尝试使用zip函数映射一些变量时(通过方法返回),结果显示为:

<zip at 0x5f24990>

我如何显示其内容?

python-3.x jupyter-notebook zip
1个回答
1
投票

将结果包装在list中:

a = ['a', 'b', 'c']
b = [1, 2, 3]

zipped = zip(a, b)
list(zipped)
[('a', 1), ('b', 2), ('c', 3)]
© www.soinside.com 2019 - 2024. All rights reserved.