Home  >  Q&A  >  body text

python - 使用xlwt 的.save保存文件excel文件,但是没有找到也没有搜索到这个文件。(看了例子,网上搜了有一段时间了,没解决)

附上代码,python 2.7

# _*_ coding:utf-8 _*_
import xlwt
import sys

wb=xlwt.Workbook()
ws=wb.add_sheet('shuju')
f=open(r'D:\car\carlist.txt')
for j in range(1,4):
    x=f.readline()
    y=x.split()
    print y
    for i in range(0,5):
        ws.write(j,i,y[i])
ws.write(10,10,"test")
stdout=sys.stdout
reload(sys)
sys.stdout=stdout
sys.setdefaultencoding('UTF-8')  
wb.save('shuju1.xls')

我保存的shuju1.xls没有找到,也搜索不到。

ringa_leeringa_lee2764 days ago507

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 17:55:50

    I just tried it again and found that the problem was solved after deleting # coding:utf-8 __. When I first looked at the learning materials, I only knew that the encoding format should be set at the beginning. I didn’t care why the encoding format was set. I need to study and study the content of this encoding.

    reply
    0
  • Cancelreply