title: Python-How to solve UnicodeEncodeError
body: <pre><code>import urllib, urllib2
  from bs4 import BeautifulSoup, Comment 
  strg=""
  iter=1
  url='http://www.amazon.in/product-reviews/B00EOPJEYK/ref=cm_cr_pr_top_link_1?    ie=UTF8&amp;pageNumber=1&amp;showViewpoints=0&amp;sortBy=bySubmissionDateDescending'
  content = urllib2.urlopen(url).read()
  soup = BeautifulSoup(content, "html.parser")
  rows =soup.find_all('div',attrs={"class" : "reviewText"})
  for row in soup.find_all('div',attrs={"class" : "reviewText"}):
        strg = strg +str(iter)+"." + row.text + "\n\n"
        iter=iter+1
  
  with open('outp.txt','w') as f:
        f.write(strg)
  f.close()
  </code></pre>
  
  <p>I require this code to write the contents of the variable,strg to the file,outp.txt.</p>
  
  <p>Instead I get this error:  </p>
  
  <pre><code>Traceback (most recent call last):
  File "C:\Python27\demo_amazon.py", line 14, in &lt;module&gt;
  f.write(strg)
  UnicodeEncodeError: 'ascii' codec can't encode character u'\u2022' in position 226:   ordinal not in range(128)     
  </code></pre>
  
  <p>strg stores the required output.There is some problem in the writing statement I guess.How to solve this?</p>
  
  <p>Kindly help.</p>
  
  <p>Thank you.</p>