I have a list being produced from a webpage using json.loads. I am displaying this with the following code:
myvar = json.loads(response.text)
print myvar[0],',',myvar[1],',',myvar[2]
This prints as:
0 , 1 , 2
What I would like it to print as is this:
0,1,2
I know I could achieve this by using .strip()
if i converted each element of the list to a string first, but this is not a valid method for a dictionary. Is there a way to strip elements of a list without converting to a string first?
Thanks
EDIT:
At request of responder, here is the full code being used:
import requests
url = 'http://www.whoscored.com/stagestatfeed'
params = {
'against': '1',
'field': '1',
'stageId': '9155',
'teamId': '32',
'type': '7'
}
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36',
'X-Requested-With': 'XMLHttpRequest',
'Host': 'www.whoscored.com',
'Referer': 'http://www.whoscored.com/Teams/32/Statistics/England-Manchester-United'}
responser = requests.get(url, params=params, headers=headers)
print '**********Shots Against (Action Zone) - Away:**********'
print '-' * 170
fixtures = json.loads(responser.text)
print("%s,%s,%s" % (fixtures[0].strip(), fixtures[1].strip(), fixtures[2].strip()))
print responser.text
print '-' * 170