title: Python 3.4: str : AttributeError: 'str' object has no attribute 'decode
body: <p>I have this code part of a function that replace badly encoded foreign characters from a string :</p>
  
  <pre><code>s = "String from an old database with weird mixed encodings"
  s = str(bytes(odbc_str.strip(), 'cp1252'))
  s = s.replace('\\x82', 'é')
  s = s.replace('\\x8a', 'è')
  (...)
  print(s)
  # b"String from an old database with weird mixed encodings"
  </code></pre>
  
  <p>I need here a "real" string, not bytes. But whend i want to decode them, i have an exception :</p>
  
  <pre><code>s = "String from an old database with weird mixed encodings"
  s = str(bytes(odbc_str.strip(), 'cp1252'))
  s = s.replace('\\x82', 'é')
  s = s.replace('\\x8a', 'è')
  (...)
  print(s.decode("utf-8"))
  # AttributeError: 'str' object has no attribute 'decode'
  </code></pre>
  
  <ul>
  <li>Do you know why s is bytes here ?</li>
  <li>Why can't i decode it to a real string ?</li>
  <li>Do you know how to do it the clean way ? (today i return s[2:][:-1]. Working but very ugly, and i would like to understand this behavior)</li>
  </ul>
  
  <p>Thanks in advance !</p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>pypyodbc in python3 use all unicode by default. That confused me. On connect, you can tell him to use ANSI.</p>
  
  <pre><code>con_odbc = pypyodbc.connect("DSN=GP", False, False, 0, False)
  </code></pre>
  
  <p>Then, i can convert the returned stuffs into cp850, which is the initial codepage of the database.</p>
  
  <pre><code>str(odbc_str, "cp850", "replace")
  </code></pre>
  
  <p>No more need to manualy replace each special character.
  Thank you very much pepr</p>