UnicodeDecodeError

by: Manish, 7 years ago


I referred this video   https://youtu.be/UF-RyxOAHQw?list=PLQVvvaa0QuDf2JswnfiGkliBInZnIC4HL and the error that I'm getting when I execute the source code provided is:


for line in plaintext.split('n'):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xed in position 6: ordinal not in range(128)

How do you rectify this error?



You must be logged in to post. Please login or register an account.



This means the text you have has some weird character in it. It depends what that character is. Sometimes you can install "unidecode" then do

from unidecode import unidecode
...
print(unidecode(YOURTEXT))


Other times you may need to declare utf-8 at the top of your script like so:
# -*- coding: utf-8 -*-


-Harrison 7 years ago

You must be logged in to post. Please login or register an account.