Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 5
    Awesome answer. Exactly what I needed. Also, great presentation to show the effect of ignore vs replace Commented Apr 11, 2017 at 12:19
  • or a.encode('ascii', 'xmlcharrefreplace') gives 'aaaàçççñññ'. Commented Apr 10, 2019 at 17:22
  • type(a) is str in Python 3.6.8 and doesn't have any encode() method. Commented Aug 24, 2019 at 10:16
  • python statement: a.encode('ascii','ignore') result: b'aaa' Commented May 21, 2021 at 3:38