1. 程式人生 > >python---檔案儲存xls格式,xlwt,xlrd的模組使用

python---檔案儲存xls格式,xlwt,xlrd的模組使用

python—檔案儲存xls格式,xlwt,xlrd的模組使用

1、使用xlwt模組新建xls檔案

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

if __name__ == "__main__":
    book = xlwt.Workbook(encoding='utf8',style_compression=0)#建立一個工作簿
    sheet = book.add_sheet("dede")
    sheet.write(0,0,'hstking')
    sheet.write(1,1,u'中文測試'.encode('utf8'))
    book.save('e:\\1.xls'
)

2、執行情況:
這裡寫圖片描述