搜索
您的当前位置:首页正文

python导出excel乱码怎么解决

2024-08-01 来源:字库网

利用python+win32com将网页的表单导出到本地excel,遇到了输出乱码问题。

相关推荐:《》

解决方法:

将x改为x.decode('utf-8')即可。

setCall('sheet1',row,col,x.decode('utf-8'))

我的部分源码:

self.xlBook = self.xlApp.Workbooks.Add()
    def setCell(self,sheet,row,col,value):#设置单元格的数据
        "Set value of one cell"
        sht = self.xlBook.Worksheets(sheet)
        print row,col
        sht.Cells(row,col).Value = value
setCall('sheet1',i,j,x.decode('utf-8'))
Top