lxml - function to return cleaned object, not just a string [closed]

teethboyes

New Member
Here is some code:\[code\]from lxml import etreeurl = 'http://www.google.com/ig/api?stock=aapl'data = http://stackoverflow.com/questions/10347054/etree.parse(url) root = data.getroot()finance = root[0]def clean(var, num): var = str(finance[num].attrib).split("'")[-2] print var\[/code\]I would like to return the variable as an object that I can call later.I know what the problem is - the str() - but don't know how to fix it as working with the variable directly doesn't allow me to to do the necessary manipulations with \[code\].attrib\[/code\] and \[code\].split\[/code\]
 
Back
Top