短小精悍算例:Python中zip()函数的用法

x = [1, 2, 3]
y = ['a', 'b', 'c']
z = zip(x, y)   # x和y中元素一一对应上
print(dict(z))        # 以字典形式输出

输出结果:
{
    
    1: 'a', 2: 'b', 3: 'c'}

猜你喜欢

转载自blog.csdn.net/weixin_39464400/article/details/106238096
今日推荐