from docx.enum.text import WD_ALIGN_PARAGRAPH
            from docx import Document
            from docx.shared import Pt,Cm
            from docx.oxml.ns import qn
            from docx.enum.table import WD_ALIGN_VERTICAL
            
            def outs(i,j,str):
                table.cell(i-1,j-1).paragraphs[0].add_run(str)   #输出函数
                
            
            
            
            doc = Document()
            doc.styles['Normal'].font.name = '宋体'
            doc.styles['Normal']._element.rPr.rFonts.set(qn('w:eastAsia'),'宋体')
            
            p1 = doc.add_paragraph()
            run = p1.add_run('个人简历表')
            run.font.name = '微软雅黑'
            run.font.size = Pt(28)
            run.bold = True
            p1.paragraph_format.alignment = WD_ALIGN_PARAGRAPH.CENTER
            
            expe = ['小学','中学','大学']
            num = 0
            
            table = doc.add_table(rows=10, cols=7)
            table.style = 'Table Grid'
            for i in range(9):
                table.rows[i].height=Cm(1.35) 
            table.rows[9].height=Cm(7)
            table.cell(0,6).width=Cm(2.5)
            table.cell(7,3).width=Cm(2.6)
            table.cell(0,0).width=Cm(2.6)
            
            table.cell(0,6).merge(table.cell(2,6))
            table.cell(2,1).merge(table.cell(2,5))
            table.cell(3,1).merge(table.cell(3,4))
            table.cell(4,0).merge(table.cell(6,0))
            for i in range(4,7):
                table.cell(i,2).merge(table.cell(i,6))
            table.cell(7,1).merge(table.cell(7,2))
            table.cell(7,4).merge(table.cell(7,6))
            table.cell(8,1).merge(table.cell(8,6))
            table.cell(9,1).merge(table.cell(9,6))
            
            
            hdr_cells = table.rows[0].cells
            hdr_cells[0].text = '姓名'
            hdr_cells[2].text = '性别'
            hdr_cells[4].text = '出生年月'
            
            hdr_cells1 = table.rows[1].cells
            hdr_cells1[0].text = '生源所在地'
            hdr_cells1[2].text = '政治面貌'
            hdr_cells1[4].text = '身高'
            
            table.cell(2,0).paragraphs[0].add_run('联系电话') 
            table.cell(3,0).paragraphs[0].add_run('毕业院校') 
            table.cell(3,5).paragraphs[0].add_run('毕业时间')
            table.cell(4,0).paragraphs[0].add_run('教育背景')
            for i in range(4,7):
                table.cell(i,1).paragraphs[0].add_run(expe[num])
                num = num + 1
            
            table.cell(7,0).paragraphs[0].add_run('外语水平')
            table.cell(7,3).paragraphs[0].add_run('计算机水平')
            table.cell(8,0).paragraphs[0].add_run('校内外职务')
            table.cell(9,0).paragraphs[0].add_run('获奖情况')
            
            for i in range(8):
                for j in range(11):
                    table.cell(i,j).paragraphs[0].paragraph_format.alignment=WD_ALIGN_PARAGRAPH.CENTER 
                    table.cell(i,j).vertical_alignment = WD_ALIGN_VERTICAL.CENTER 
            table.cell(9,0).vertical_alignment = WD_ALIGN_VERTICAL.CENTER
            
            table.cell(0,1).paragraphs[0].add_run('黄柯源') 
            table.cell(0,3).paragraphs[0].add_run('男') 
            
            run1=table.cell(0,6).paragraphs[0].add_run()
            picture =run1.add_picture(r'C:\Users\11724\Desktop\1寸.jpg')
            picture.height=Cm(3.5)#设置图片高度
            picture.width=Cm(2.5)#设置图片宽度
            
            outs(1,6,'2001.2.27')
            outs(2,2,'江西')
            outs(2,4,'团员')
            outs(2,6,'180')
            
            
            
            doc.save(r'C:\Users\11724\Desktop\简历.docx')