Python throws this error. I want to solve it but the problem is my data (.txt files) gow through a package. How can I solve this? Maybe I can instruct my computer to encode in a different way if it encounters encoding in the package or something? Thanks in advance for the answer.
Asked
Active
Viewed 1,296 times
-1
-
If you can control the encoding process, make sure you encode your txt file as UTF-8, which is the de-facto standard on the internet and the actual standard in Python. If you are given this txt file and cannot recreate it, you must determine what encoding was used to encode it, then pass that to `decode` when you decode it. – mCoding Nov 18 '20 at 15:51
1 Answers
0
If you are opening, then open with encoding:
open('txt.tsv', encoding='YOUR_ENCODING')
And if you are dumping then:
s.encode('utf-8').strip()
Where s
is the string variable

Wasif
- 14,755
- 3
- 14
- 34