• 学习使用Python的python-docx库生成Word文档。
  • 理解文档结构和样式设置。
 
from docx import Document

def create_word_report(hot_words, explanations, file_path):
    doc = Document()
    doc.add_heading("信息领域热词报告", level=1)
    for word in hot_words:
        doc.add_paragraph(f"{word}: {explanations[word]}")
    doc.save(file_path)

create_word_report(hot_words, explanations, "hot_word_report.docx")