python 读写文件

1.python 读写excel文件
读取文件使用xlrd 包.
参考资料
python 支持中文,需要在首行中加入

#_*_coding:utf-8_*_
import xlrd
def read_xls():
  xlsname = '/Users/deepmind/Downloads/data.xlsx'
  data = xlrd.open_workbook(xlsname)
  table = data.sheets()[0]
  for i in range(1,table.nrows):
      for j in range(table.ncols):
          x = table.row(i)[j].value
          print x

python 读写word文档

from docx import Document
document = Document()
document.add_paragraph('This is a paragraph')
document.save('doc_test.docx')

你可能感兴趣的:(python,Excel,doc)