How to display the "%" in python.
I found so far two methods:
>>> print "See %d%%" % (0.77 * 100)
See 77%
>>> print "See {0:.0%}".format(0.77)
See 77%
>>>
Is a blog about python programming language. You can see my work with python programming language, tutorials and news.
>>> print "See %d%%" % (0.77 * 100)
See 77%
>>> print "See {0:.0%}".format(0.77)
See 77%
>>>
>>> import geo
>>> geo.adress("Santa Claus")
{'status': '200', 'latitude': '32.1715776', 'longitude': '-82.3315138', 'accuracy': '4'}
from xml.dom import minidom as dom import urllib def fetchPage(url): a = urllib.urlopen(url) return ''.join(a.readlines()) def extract(webpage): a = dom.parseString(webpage) item2 = a.getElementsByTagName('SendingDate')[0].firstChild.wholeText print "DATA ",item2 item = a.getElementsByTagName('Cube') for i in item: if i.hasChildNodes() == True: eur = i.getElementsByTagName('Rate')[10].firstChild.wholeText dol = i.getElementsByTagName('Rate')[26].firstChild.wholeText print "EURO ",eur print "DOLAR ",dol if __name__=='__main__': webpage = fetchPage("http://www.bnro.ro/nbrfxrates.xml") extract(webpage)The result is:
$python xmlparse.py DATA 2010-02-04 EURO 4.1214 DOLAR 2.9749With "urllib" package I read the url.