1 例子一: 2 p = ["a","b","c","d","e","f","g"] 3 o =[0, 0, 0, 0, 0, 1, 1] 4 print type(o) 5 d = {} 6 for i in range(len(p)): 7 d[p[i]] = o[i] 8 print d 9 10 11 例子二 12 参考的例子: 13 ls1 = [‘PID‘, ‘USERNAME‘, ‘THR‘, ‘PRI‘, ‘NICE‘, ‘SIZE‘, ‘RES‘, ‘STATE‘, ‘TIME‘, ‘WCPU‘, ‘COMMAND‘] 14 ls2 = [‘32‘, ‘root‘, ‘1‘, ‘-36‘, ‘-155‘, ‘0K‘, ‘16K‘, ‘WAIT‘, ‘0:00‘, ‘0.00%‘, ‘swi3:‘, ‘ip6opt‘, ‘ipopt‘] 15 ls3 = ls2[0:10] 16 ls3.append(" ".join(ls2[10:])) 17 d = {} 18 for i in range(len(ls1)): 19 d[ls1[i]] = ls3[i] 20 print d
工作上,使用redis获取都的数据。每次都是一大串。不知道什么意思;
于是找了一下怎么将2个list的数据结合在一起。就可以方便的查看到获取的数据
时间: 2024-10-31 19:59:55