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

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -