python - How do I make my script interpret a user-provided string expression? -


i'm trying develop python script can pass xmldict argument command line , have return value.

i know still need add argv code, right i'm trying python read print statement variable. no luck far. print statement prints vv string. i'm using 2.7.2 can use python 3 if it's easier.

#!/usr/bin/python  import xmltodict  document_file = open("file.xml", "r")  original_doc = document_file.read()  document = xmltodict.parse(original_doc)   day = document['weather']['dayf']['day']  vv='day[2][\'hi\']'  print "{0} ".format(vv)  print "{0} ".format(day[2]['hi']) 


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -