Python eval integer in string, and return integer instead of ascii char -


i'm getting data file, looks this:

[200, "hello", "world"] 

now, since file, array inside string; turn array using eval(). works fine integer @ start converted ascii char, instead of integer want (the euro sign).

how can fix this?

you use simplejson module. e.g.

>>> import simplejson >>> = simplejson.loads('[200, "hello", "world"]') >>> print [200, 'hello', 'world'] 

this way "malicious" data such os.execvp() not evaluated jsondecodeerrorwould thrown.


Comments

Popular posts from this blog

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -