python在使用xlwt创建excel并写入数据后,手动打开demo.xlsx时提示文件扩展名无效,但是用xlrd模块读取没问题:

# coding:utf-8
import xlwt, xlrd

# 写入excel
file = xlwt.Workbook()
table = file.add_sheet("sheet1", cell_overwrite_ok=True)
table.write(0, 0, 'test')
table.write(0, 0, u'这就蛋疼了')
file.save("
demo.xls")

# 读取excel
data = xlrd.open_workbook('F:/pythonscirpt/AutoTest/Data-Driven/demo.xls')
tabel1 = data.sheet_by_index(0)
cell_A1 = tabel1.cell(0, 0).value
print cell_A1
print tabel1.name

# 输出结果
>>这就蛋疼了
sheet1

后来把demo.xlsx改为demo.xls,再去手动打开就可以了