0

I have a dictionary in a specific file, when I try to run it from other file importing it:

import resultado
print ( resultado.dic["10101027"])

I have the following error:

SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xba in position 38: invalid start byte

resultado file:

dic = {

"10101027":"UNIDAD EDUCATIVA DISTRITAL ANTONIO ORNESBARRIO SAN JOSE COTIZA FRENTE CALLE LOS EUCALIPTUS. DERECHA ESCALERA SAN MARCOS. IZQUIERDA ESCALERA SAN JUDA FRENTE AL PARQUE ANDRES GALARRAGA EDIFICIO",
"10101001":"UNIDAD EDUCATIVA DISTRITAL MADARIAGASECTOR ALTAGRACIA DERECHA CALLE CONCORDIA. IZQUIERDA CALLE DELICIAS. FRENTE CALLE DELICIAS A CONCORDIA AL FRENTE COLEGIO BELUTINI CASA",
"10101002":"UNIDAD EDUCATIVA SANTA BARBARASECTOR SANTA BARBARA DERECHA CALLE PARAISO. IZQUIERDA CALLE DOCTOR GONZALEZ. FRENTE CALLE PARAISO FRENTE ESQUINAS DOCTOR GONZALEZ A PARAISO EDIFICIO",
}
0

1 Answer 1

2

The message seems pretty clear, at least with respect to the limited amount of information you provide: you've got a byte 186 (0xba) in one of the files, which means Python fails to parse the file as UTF-8.

In ISO-8859-1, 0xba is "º", so if you see this character (likely in a string) when opening files it's possible that your editor automatically infers encoding when not UTF-8, and that the file is either mis-written or mis-declared as UTF-8.

Without the exact file content as-is (copy/paste might be subject to automated transcoding from your editor) it's hard to say more. You may want to run the file utility on your various files to see what that says though.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.