I have a python file like this
import urllib2
try:
data = urllib2.urlopen('http:....').read()
except urllib2.HTTPError, e:
print "HTTP error: %d" % e.code
except urllib2.URLError, e:
print "Network error: %s" % e.reason.args[1]
print data1
the output looks like this
>>>
15.95
>>>
I need to perform some manipulation of data1 (or any alternate variable) so that when I print data1 (or the new variable) the output does not have the extra line. In other words I want it to look like this:
>>>
15.95
>>>
Any help would be great I am relatively new to python. I have been screwing around with \r and cannot seem to get it to work.
Perhaps you just need to strip whitespace from your variable? Use
data1.strip(). Read up on str.strip() for more information.By the way, to see the whitespace explicitly, use
print repr(data1).