10.有字符串 "k:1|k1:2|k2:3|k3:4" 处理成字典 {‘k‘:1,‘k1‘:2....}
s = "k:1|k1:2|k2:3|k3:4" dic = {} l1 = s.split(‘|‘) for i in l1: k,v = i.split(‘:‘) dic[k] = v print(dic)
原文地址:https://www.cnblogs.com/apollo1616/p/9460543.html
时间: 2024-11-08 22:48:45
10.有字符串 "k:1|k1:2|k2:3|k3:4" 处理成字典 {‘k‘:1,‘k1‘:2....}
s = "k:1|k1:2|k2:3|k3:4" dic = {} l1 = s.split(‘|‘) for i in l1: k,v = i.split(‘:‘) dic[k] = v print(dic)
原文地址:https://www.cnblogs.com/apollo1616/p/9460543.html