[Solved] Convert string to Ordered Dictionary [closed]


You can try something like this :

input_st = "Field1:'abc',Field2:'HH:MM:SS',Field3:'d,b,c'"

output_st = {item.split(":")[0]:":".join(item.split(":")[1:]).replace("'", "") for item in input_st.split("',")}

outputs :

{'Field1': 'abc', 'Field2': 'HH:MM:SS', 'Field3': 'd,b,c'}

Kind of ugly but it does the job.

4

solved Convert string to Ordered Dictionary [closed]