資源簡介
ExceltoWord
代碼片段和文件信息
#!?/usr/bin/env?python
#?-*-?coding:utf-8?-*-
import?xlrd
from?docx?import?Document
from?docx.enum.table?import?WD_TABLE_ALIGNMENT
import?MySQLdb
def?open_excel(filename=‘stu_info.xlsx‘):
????try:
????????data?=?xlrd.open_workbook(filename)
????????table?=?data.sheets()[0]
????????return?table
????except?Exception?e:
????????print?str(e)
????????return?None
def?get_data_by_coord(table?row=0?col=0):
????try:
????????data?=?table.row_values(row)[col]
????????return?data
????except?Exception?e:
????????print(str(e))
????????return?None
def?get_student_info(table?row):
????try:
????????student?=?table.row_values(row)
????????return?student
????except?Exception?e:
????????print?str(e)
????????return?None
def?strip(string):
????start?=?0
????en
- 上一篇:解決地圖填色問題
- 下一篇:獲取win系統常用參數
評論
共有 條評論