{"id":910,"date":"2015-03-22T23:44:19","date_gmt":"2015-03-22T23:44:19","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2015\/03\/22\/python-split-a-string-into-a-dictionary\/"},"modified":"2021-07-24T15:41:02","modified_gmt":"2021-07-24T15:41:02","slug":"python-split-a-string-into-a-dictionary","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/Programming\/Python\/python-split-a-string-into-a-dictionary.html","title":{"rendered":"Python – Split a String into a Dictionary"},"content":{"rendered":"
To split a string into key value pairs (i.e dict) the following can be used,<\/p>\n
>>> string = \"abc=123,xyz=456\" >>> dict(x.split('=') for x in string.split(',')) {'xyz': '456', 'abc': '123'}<\/pre>\n","protected":false},"excerpt":{"rendered":"To split a string into key value pairs (i.e dict) the following can be used, >>> string = “abc=123,xyz=456” >>> dict(x.split(‘=’) for x in string.split(‘,’)) {‘xyz’: ‘456’, ‘abc’: ‘123’}<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"yoast_head":"\n
Python - Split a String into a Dictionary - Fir3net<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n