小编Kap*_*oni的帖子

为什么列表中的字典是分开的

Name = []
Address = []
for a in range(1):
    Name = raw_input ('Enter Name: ')
    Address = raw_input ('Enter Address: ')
    print Name
    print Address
    print [dict(zip(Name, e)) for  e in Address]
    a +=1
Run Code Online (Sandbox Code Playgroud)

这就是我得到的

Enter Name: Kapil
Enter Address: Soni
Kapil
Soni
[{'K': 'S'}, {'K': 'o'}, {'K': 'n'}, {'K': 'i'}]
Run Code Online (Sandbox Code Playgroud)

我想创建如下

{'Kapil':'Soni'}
Run Code Online (Sandbox Code Playgroud)

我做错了什么?

python dictionary list

0
推荐指数
1
解决办法
65
查看次数

标签 统计

dictionary ×1

list ×1

python ×1