http://scienceoss.com/read-excel-files-from-python/comment-page-1/#comment-1051
在上面的链接中,我使用此实用程序来读取 XLS 文件。如果 XLS 文件包含不同的语言字符,如中文或印地语,则无法正确输出。有解决方法吗?
谷歌搜索后,我发现了这个:
import xlrd
def upload_xls(dir,file,request):
try:
global msg
global row_num
row_num = []
header_arr = []
global file_path
file_path = dir
#reader = csv.reader(open(file), delimiter='#', quotechar='"')
book = xlrd.open_workbook('dodgy.xls',encoding='cp1252') ##To specify UTF8-encoding
wb.sheet_names()
sh = wb.sheet_by_index(0)
valid_xl_format = 0
invalid_xl_format = 0
except:
print "Error
但是行中有一个错误book = open_workbook('dodgy.xls',encoding='cp1252')
:
TypeError: open_workbook() got an unexpected keyword argument 'encoding'