简体   繁体   中英

Read special chars in an excel using xlrd

I am reading an excel which has Norwegian chars in one of the columns using xlrd, while printing the column values on console it's not printing the actual values.

wb = open_workbook(ip_path+"input.xlsx",encoding_override="cp865")

Eg: Reading ===> abcdefg Lømnopq

Expected Output on console =====> "abcdefg Lømnopq"

But its printing =====> abcdefg Lr\\xf8mnopq

You are reading from the file using the encoding, so you need to decode it when printing. Your print command should look like this:

print(cell_value.decode("cp865"))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM