Home > other >  How to solve the problem of string coding garbled
How to solve the problem of string coding garbled

Time:12-16

How to solve the problem of string coding garbled

The import pandas as pd
Df=pd read_excel (r 'C: \ Users \ mi \ Desktop \ fund XLSX', \
The header=0, sep='\ t' encoding="utf-8")
Df. Fillna ({" securities referred to as ":" good "})

But running, appeared the following the code
In: runfile (' C:/Users/mi/. Spyder - py3/temp. Py ', wdir='C:/Users/mi/. Spyder - py3')
This command failed to be executed because an error occurred while trying to get the file code from Spyder 's editor. The error was:


An exception has occurred, the use % TB to see the full traceback.

UnicodeDecodeError: 'GBK' codec can 't decode byte 0 x80 position in 181: illegal multibyte sequence

How to solve this problem, thank you all for the great god

CodePudding user response:

Guess: change 'utf-8' to 'GBK' try
  • Related