1、字典转化为列表
a={"username":"12","password":"89"}
print a.items()
运行结果:》》》
[('username', '12'), ('password', '89')]
2、字典转化为字符串
a={"username":"12","password":"89"}
for key,val in a.items():
print ky,val
运行结果:》》》
username 12
password 89
3、两个列表合并为一个列表并转化为字典
a=["a,b,c,d","1,2,3,4","sad,good,apple,goal","wqqw"]
b=["1.3","2.3","2.9","5.6"]
c=dict(zip(a,b))
print zip(a,b)
print c
运行结果:》》》
[('a,b,c,d', '1.3'), ('1,2,3,4', '2.3'), ('sad,good,apple,goal', '2.9'), ('wqqw', '5.6')]
{'wqqw': '5.6', '1,2,3,4': '2.3', 'sad,good,apple,goal': '2.9', 'a,b,c,d': '1.3'}