How to remove non-ASCII characters in Python

Removing non-ASCII characters results in a string that only contains ASCII characters. For example, removing non-ASCII characters from “àa string withé fuünny charactersß” results in “a string with funny characters”.

Solution for How to remove non-ASCII characters in Python : You can use str.encode() to remove non-ASCII characters Call str.encode(encoding, errors) with encoding as “ASCII” and errors as “ignore” to return str without “ASCII” characters. Use str.decode() to encode str.


how-to-remove-non-ascii-characters-in-python