title: Remove a degree symbol from a string using Python
body: <p>I am using Python to read a text file of data line by line.  One of the lines contains a degree symbol. I want to alter this part of the string. My script uses <code>line = line.replace("TEMP [°C]", "TempC")</code>.  My code stops at this line but does not change the sting at all nor does it throw an error.  Clearly there is something about my replace such that the script does not see the 'TEMP [°C]' as existing in my string.</p>
  
  <p>In order to insert the degree sign in my script I had to change the encoding to UTF-8 in my IDE file settings.  I have included the following text at the top of my script.</p>
  
  <pre><code>#!/usr/bin/env python
  # -*- coding: utf-8 -*-
  </code></pre>
  
  <p>How do I replace 'TEMP [°C]' with 'TempC'?</p>
  
  <p>I am using Windows 7 and Python 2.7 with Komodo IDE 5.2</p>
  
  <p>I have tried running the suggested code in a Python Shell in Komodo and that changed the file.</p>
  
  <pre><code># -*- coding: utf-8 -*-
  line = "hello TEMP [°C]"
  line = line.replace("TEMP [°C]", "TempC")
  print(line)
  hello TempC
  </code></pre>
  
  <p>This suggested code in a Python Shell in Komodo returned this.</p>
  
  <pre><code>line = "TEMP [°C]"
  line = line.replace(u"TEMP [°C]", "TempC")
  Traceback (most recent call last):
  File "&lt;console&gt;", line 0, in &lt;module&gt;
  UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 6: ordinal not in range(128)
  </code></pre>
  
  <p>None of these suggestions worked when reading my text file though.</p>