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
Post a Comment