
ws=wb.active
row =[re.sub('None','',str(c.value)) for c in list(ws.rows)[0]]
print(row)
对于word文档中表格,用如下处理办法,经测试有效:
import docx
from docx import Document
doc_file = 't3.docx'
document = Document(doc_file)
tables = document.tables # 获取文档中的所有表格
table = tables[0] # 提取文档中的第一个表格
for col in range(len(table.columns)):
table.cell(0, col).text = table.cell(0, col).text.replace('None','')
document.save('t3.docx')
如对你有帮助,请在回答的右上方采纳按钮上点击一下。