字符串转化为字典
str = “字:1,符:2,串:3,转:4,字:5,典:6”
def strtodict(str):
dic = {}
for i in str.split(’,’):
key,value = i.split(’:’)
dic[key] = value
print(dic)
strtodict(str)
字符串转化为字典
str = “字:1,符:2,串:3,转:4,字:5,典:6”
def strtodict(str):
dic = {}
for i in str.split(’,’):
key,value = i.split(’:’)
dic[key] = value
print(dic)
strtodict(str)