def string_to_dict(raw_data):
items = raw_data.split(",")
result = {}
for item in items:
key, value = item.split(":")
result[key] = value
return result
raw_data = "id:101,name:python,level:gold"
ret = string_to_dict(raw_data)
print(ret) # {'id': '101', 'name': 'python', 'level': 'gold'}
To embed this project on your website, copy the following code and paste it into your website's HTML: