python - How to Convert Tuple to Dictionary? -
i'm using python 2.5 , win xp. have tuple below:
>>> (none, '{1: 2, 2: 4, 3: 6, 4: 8, 5: 10, 6: 12}') >>> a[1] '{1: 2, 2: 4, 3: 6, 4: 8, 5: 10, 6: 12}' >>> i want convert tuple a[1] dictionary because want use key , value. pls advise. tq
>>> import ast >>> ast.literal_eval(a[1]) {1: 2, 2: 4, 3: 6, 4: 8, 5: 10, 6: 12}
Comments
Post a Comment