python - Transform Dictionary-Like Input to a Dictionary -


how transform dictionary input real dictionary can process?

when execute external command, get.

{'aaa': {'test_a': 0.11666666666667,          'test_b': 1,          'total_c': 0.11666666666667},  'bbb': {'test_a': 32.883333333332999,          'test_b': 1,          'total_c': 0.11666666666667},  'ccc': {'test_a': 11, 'test_b': 31, 'test'_c': 33}} 

so, can see, above dictionary-format already. thinking of doing like.

 #!/usr/bin/python   import command  result = commands.getoutput('<execute_external_command') 

so 'result' becomes dictionary , can process dictionary.

from simplejson import loads result='{"name":"anton"}' dictionary=loads(result) print dictionary  result="{'name':'anton'}" dictionary=loads(result.replace("'",'"')) print dictionary 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -