from docx import Document
from docx.shared import Inches
import json

class build_doc():
    def __init__(self):
        self.document = Document()

    def add_title(self, doc_name= 'chengyu_story'):
        self.document.add_heading(doc_name, 0)
    
    def add_content(self, title, text):
        self.document.add_heading(title, level=1)
        # self.document.add_picture(image, width=Inches(5))
        self.document.add_paragraph(text)
        
    def add_page(self):
        self.document.add_page_break()

    def save_doc(self, name= 'chengyu_story.docx'):
        self.document.save(name)

data = json.load(open('chengyu_data\chengyu_content.json', 'r', encoding='utf-8'))

doc = build_doc()
i = 0
for data_info in data:
    i += 1
    id = str(i).rjust(4, '0')
    doc.add_title(id)
    doc.add_content(data_info['title'], data_info['content'].replace('\r\n\t\t\t\t　　', '\n'))

doc.save_doc()
3b80300c3d772e04c392c6c4e2e359fac4852094
<mask token>


class build_doc:

    def __init__(self):
        self.document = Document()

    def add_title(self, doc_name='chengyu_story'):
        self.document.add_heading(doc_name, 0)

    def add_content(self, title, text):
        self.document.add_heading(title, level=1)
        self.document.add_paragraph(text)
    <mask token>

    def save_doc(self, name='chengyu_story.docx'):
        self.document.save(name)


<mask token>

<mask token>


class build_doc:

    def __init__(self):
        self.document = Document()

    def add_title(self, doc_name='chengyu_story'):
        self.document.add_heading(doc_name, 0)

    def add_content(self, title, text):
        self.document.add_heading(title, level=1)
        self.document.add_paragraph(text)

    def add_page(self):
        self.document.add_page_break()

    def save_doc(self, name='chengyu_story.docx'):
        self.document.save(name)


<mask token>
for data_info in data:
    i += 1
    id = str(i).rjust(4, '0')
    doc.add_title(id)
    doc.add_content(data_info['title'], data_info['content'].replace(
        '\r\n\t\t\t\t\u3000\u3000', '\n'))
doc.save_doc()

<mask token>


class build_doc:

    def __init__(self):
        self.document = Document()

    def add_title(self, doc_name='chengyu_story'):
        self.document.add_heading(doc_name, 0)

    def add_content(self, title, text):
        self.document.add_heading(title, level=1)
        self.document.add_paragraph(text)

    def add_page(self):
        self.document.add_page_break()

    def save_doc(self, name='chengyu_story.docx'):
        self.document.save(name)


data = json.load(open('chengyu_data\\chengyu_content.json', 'r', encoding=
    'utf-8'))
doc = build_doc()
i = 0
for data_info in data:
    i += 1
    id = str(i).rjust(4, '0')
    doc.add_title(id)
    doc.add_content(data_info['title'], data_info['content'].replace(
        '\r\n\t\t\t\t\u3000\u3000', '\n'))
doc.save_doc()

from docx import Document
from docx.shared import Inches
import json


class build_doc:

    def __init__(self):
        self.document = Document()

    def add_title(self, doc_name='chengyu_story'):
        self.document.add_heading(doc_name, 0)

    def add_content(self, title, text):
        self.document.add_heading(title, level=1)
        self.document.add_paragraph(text)

    def add_page(self):
        self.document.add_page_break()

    def save_doc(self, name='chengyu_story.docx'):
        self.document.save(name)


data = json.load(open('chengyu_data\\chengyu_content.json', 'r', encoding=
    'utf-8'))
doc = build_doc()
i = 0
for data_info in data:
    i += 1
    id = str(i).rjust(4, '0')
    doc.add_title(id)
    doc.add_content(data_info['title'], data_info['content'].replace(
        '\r\n\t\t\t\t\u3000\u3000', '\n'))
doc.save_doc()

from docx import Document
from docx.shared import Inches
import json

class build_doc():
    def __init__(self):
        self.document = Document()

    def add_title(self, doc_name= 'chengyu_story'):
        self.document.add_heading(doc_name, 0)
    
    def add_content(self, title, text):
        self.document.add_heading(title, level=1)
        # self.document.add_picture(image, width=Inches(5))
        self.document.add_paragraph(text)
        
    def add_page(self):
        self.document.add_page_break()

    def save_doc(self, name= 'chengyu_story.docx'):
        self.document.save(name)

data = json.load(open('chengyu_data\chengyu_content.json', 'r', encoding='utf-8'))

doc = build_doc()
i = 0
for data_info in data:
    i += 1
    id = str(i).rjust(4, '0')
    doc.add_title(id)
    doc.add_content(data_info['title'], data_info['content'].replace('\r\n\t\t\t\t　　', '\n'))

doc.save_doc()