diff --git a/main.py b/main.py index 7f17772..186bc11 100644 --- a/main.py +++ b/main.py @@ -32,7 +32,7 @@ def gen_filelist(pages, path = os.path.abspath('.')): page_curr = 1 type_curr = 0 for filename in file_list: - if int(filename[0:1]) != page_curr or filename[2] != types[type_curr % 3]: + if int(filename[0:2]) != page_curr or filename[2] != types[type_curr % 3]: return [] else: type_curr += 1 @@ -55,10 +55,18 @@ def gen_docx(): if len(file_list) != 0: pic_count = 0 for filename in file_list: - doc.add_picture(filename, height = Inches(2.5)) pic_count += 1 - if pic_count % 3 == 0 and pic_count != len(file_list): - doc.add_page_break() + if pic_count % 3 == 1: + doc.add_picture(filename, height = Inches(2.5)) + table = doc.add_table(rows = 1, cols = 2) + elif pic_count % 3 == 2: + cell1 = table.cell(0, 0) + cell1.paragraphs[0].add_run().add_picture(filename, height = Inches(5.0)) + elif pic_count % 3 == 0: + cell2 = table.cell(0, 1) + cell2.paragraphs[0].add_run().add_picture(filename, height = Inches(5.0)) + if pic_count != len(file_list): + doc.add_page_break() else: print("请检查文件命名是否正确!") doc.save("output.docx")