Try setting the system default encoding as utf-8
at the start of the script, so that all strings are encoded using that.
Example –
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
The above should set the default encoding as utf-8
.
More Related Contents:
- Replace non-ASCII characters with a single space
- Why does Python print unicode characters when the default encoding is ASCII?
- Character reading from file in Python
- Python – Unicode to ASCII conversion
- UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xa0′ in position 20: ordinal not in range(128)
- How to remove \xa0 from string in Python?
- How can I remove non-ASCII characters but leave periods and spaces?
- How to check if a string in Python is in ASCII?
- Convert Unicode to ASCII without errors in Python
- Python string prints as [u’String’]
- Windows cmd encoding change causes Python crash
- Python UnicodeDecodeError – Am I misunderstanding encode?
- Python and BeautifulSoup encoding issues [duplicate]
- Get a list of all the encodings Python can encode to
- Non-ASCII characters in Matplotlib
- How do I check if a string is unicode or ascii?
- How to print UTF-8 encoded text to the console in Python < 3?
- ‘UCS-2’ codec can’t encode characters in position 1050-1050
- Why doesn’t Python recognize my utf-8 encoded source file?
- How to correctly parse UTF-8 encoded HTML to Unicode strings with BeautifulSoup? [duplicate]
- In Python, how do I decode GZIP encoding?
- Python 3: How to specify stdin encoding
- Python ascii utf unicode
- How do I treat an ASCII string as unicode and unescape the escaped characters in it in python?
- How to detect string byte encoding?
- Convert “\x” escaped string into readable string in python
- python encoding utf-8
- How does unicodedata.normalize(form, unistr) work?
- Python – dealing with mixed-encoding files
- UnicodeDecodeError when performing os.walk