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

附上代码,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_lee
ringa_lee

ringa_lee

reply all(1)
左手右手慢动作

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!