S
S
Samarkand2017-06-27 21:58:13
Python
Samarkand, 2017-06-27 21:58:13

How to work with encodings in Python?

Task: load json from a file, process the data and save it to another file in json format.
Script and data encoding utf8.
# -*- coding: utf-8 -*-
How to stop writing this?
print s.encode("utf8")
How to get rid of these errors:

UnicodeDecodeError: 'ascii' codec can't decode byte

They are completely irrelevant, but I don’t encode or decode anything: all data is in the same utf8 encoding.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Michurin, 2017-06-27
@Samarkand

Switch to Python 3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question