python - the program shows unicode error -


the below program shows unicode error

import urllib2 import csv import requests bs4 import beautifulsoup url = 'http://www.icc-cricket.com/associate-affiliate-rankings' response = requests.get(url) html = response.content soup = beautifulsoup(html) table= soup.find('div', attrs={'class': 'associaterankings'}) list_of_rows = [] row in table.findall('tr'):     list_of_cells = []     cell in row.findall('td'):         text = cell.text.replace(' ', '')         list_of_cells.append(text)     list_of_rows.append(list_of_cells)  outfile = open("./i.csv", "wb") writer = csv.writer(outfile) writer.writerows(list_of_rows) 

error:

traceback (most recent call last):   file "f:\web\hi.py", line 20, in <module>     writer.writerows(list_of_rows) unicodeencodeerror: 'ascii' codec can't encode character u'\xa0' in position 0: ordinal not in range(128) 

how fix error?


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -