Hướng dẫn what is pptx in python? - pptx trong python là gì?
Một cách nhanh chóng để bắt đầu là bằng cách thử một số ví dụ dưới đây để cảm nhận cách sử dụng Python-PPTX. Show
Tài liệu API có thể giúp bạn với các chi tiết tốt về chữ ký và hành vi gọi điện.API documentation can help you with the fine details of calling signatures and behaviors. Chào thế giới! thí dụ¶from pptx import Presentation prs = Presentation() title_slide_layout = prs.slide_layouts[0] slide = prs.slides.add_slide(title_slide_layout) title = slide.shapes.title subtitle = slide.placeholders[1] title.text = "Hello, World!" subtitle.text = "python-pptx was here!" prs.save('test.pptx') Ví dụ trượt đạnfrom pptx import Presentation prs = Presentation() bullet_slide_layout = prs.slide_layouts[1] slide = prs.slides.add_slide(bullet_slide_layout) shapes = slide.shapes title_shape = shapes.title body_shape = shapes.placeholders[1] title_shape.text = 'Adding a Bullet Slide' tf = body_shape.text_frame tf.text = 'Find the bullet slide layout' p = tf.add_paragraph() p.text = 'Use _TextFrame.text for first bullet' p.level = 1 p = tf.add_paragraph() p.text = 'Use _TextFrame.add_paragraph() for subsequent bullets' p.level = 2 prs.save('test.pptx') Không phải tất cả các hình dạng có thể chứa văn bản, nhưng những hình dạng luôn có ít nhất một đoạn, ngay cả khi đoạn đó trống và không có văn bản nào có thể nhìn thấy trong hình dạng. from pptx import Presentation prs = Presentation() bullet_slide_layout = prs.slide_layouts[1] slide = prs.slides.add_slide(bullet_slide_layout) shapes = slide.shapes title_shape = shapes.title body_shape = shapes.placeholders[1] title_shape.text = 'Adding a Bullet Slide' tf = body_shape.text_frame tf.text = 'Find the bullet slide layout' p = tf.add_paragraph() p.text = 'Use _TextFrame.text for first bullet' p.level = 1 p = tf.add_paragraph() p.text = 'Use _TextFrame.add_paragraph() for subsequent bullets' p.level = 2 prs.save('test.pptx')1. Như một lối tắt, các thuộc tính có thể ghi from pptx import Presentation prs = Presentation() bullet_slide_layout = prs.slide_layouts[1] slide = prs.slides.add_slide(bullet_slide_layout) shapes = slide.shapes title_shape = shapes.title body_shape = shapes.placeholders[1] title_shape.text = 'Adding a Bullet Slide' tf = body_shape.text_frame tf.text = 'Find the bullet slide layout' p = tf.add_paragraph() p.text = 'Use _TextFrame.text for first bullet' p.level = 1 p = tf.add_paragraph() p.text = 'Use _TextFrame.add_paragraph() for subsequent bullets' p.level = 2 prs.save('test.pptx')2 và from pptx import Presentation prs = Presentation() bullet_slide_layout = prs.slide_layouts[1] slide = prs.slides.add_slide(bullet_slide_layout) shapes = slide.shapes title_shape = shapes.title body_shape = shapes.placeholders[1] title_shape.text = 'Adding a Bullet Slide' tf = body_shape.text_frame tf.text = 'Find the bullet slide layout' p = tf.add_paragraph() p.text = 'Use _TextFrame.text for first bullet' p.level = 1 p = tf.add_paragraph() p.text = 'Use _TextFrame.add_paragraph() for subsequent bullets' p.level = 2 prs.save('test.pptx')3 được cung cấp để hoàn thành điều tương tự. Lưu ý rằng hai cuộc gọi cuối cùng đã xóa tất cả các đoạn văn hình dạng ngoại trừ đoạn đầu tiên trước khi đặt văn bản mà nó chứa. from pptx import Presentation prs = Presentation() bullet_slide_layout = prs.slide_layouts[1] slide = prs.slides.add_slide(bullet_slide_layout) shapes = slide.shapes title_shape = shapes.title body_shape = shapes.placeholders[1] title_shape.text = 'Adding a Bullet Slide' tf = body_shape.text_frame tf.text = 'Find the bullet slide layout' p = tf.add_paragraph() p.text = 'Use _TextFrame.text for first bullet' p.level = 1 p = tf.add_paragraph() p.text = 'Use _TextFrame.add_paragraph() for subsequent bullets' p.level = 2 prs.save('test.pptx') 4 Ví dụ Enfrom pptx import Presentation from pptx.util import Inches, Pt prs = Presentation() blank_slide_layout = prs.slide_layouts[6] slide = prs.slides.add_slide(blank_slide_layout) left = top = width = height = Inches(1) txBox = slide.shapes.add_textbox(left, top, width, height) tf = txBox.text_frame tf.text = "This is text inside a textbox" p = tf.add_paragraph() p.text = "This is a second paragraph that's bold" p.font.bold = True p = tf.add_paragraph() p.text = "This is a third paragraph that's big" p.font.size = Pt(40) prs.save('test.pptx') from pptx import Presentation prs = Presentation() bullet_slide_layout = prs.slide_layouts[1] slide = prs.slides.add_slide(bullet_slide_layout) shapes = slide.shapes title_shape = shapes.title body_shape = shapes.placeholders[1] title_shape.text = 'Adding a Bullet Slide' tf = body_shape.text_frame tf.text = 'Find the bullet slide layout' p = tf.add_paragraph() p.text = 'Use _TextFrame.text for first bullet' p.level = 1 p = tf.add_paragraph() p.text = 'Use _TextFrame.add_paragraph() for subsequent bullets' p.level = 2 prs.save('test.pptx') 5 Ví dụ Enfrom pptx import Presentation from pptx.util import Inches img_path = 'monty-truth.png' prs = Presentation() blank_slide_layout = prs.slide_layouts[6] slide = prs.slides.add_slide(blank_slide_layout) left = top = Inches(1) pic = slide.shapes.add_picture(img_path, left, top) left = Inches(5) height = Inches(5.5) pic = slide.shapes.add_picture(img_path, left, top, height=height) prs.save('test.pptx') from pptx import Presentation prs = Presentation() bullet_slide_layout = prs.slide_layouts[1] slide = prs.slides.add_slide(bullet_slide_layout) shapes = slide.shapes title_shape = shapes.title body_shape = shapes.placeholders[1] title_shape.text = 'Adding a Bullet Slide' tf = body_shape.text_frame tf.text = 'Find the bullet slide layout' p = tf.add_paragraph() p.text = 'Use _TextFrame.text for first bullet' p.level = 1 p = tf.add_paragraph() p.text = 'Use _TextFrame.add_paragraph() for subsequent bullets' p.level = 2 prs.save('test.pptx') 6 Ví dụ Enfrom pptx import Presentation from pptx.enum.shapes import MSO_SHAPE from pptx.util import Inches prs = Presentation() title_only_slide_layout = prs.slide_layouts[5] slide = prs.slides.add_slide(title_only_slide_layout) shapes = slide.shapes shapes.title.text = 'Adding an AutoShape' left = Inches(0.93) # 0.93" centers this overall set of shapes top = Inches(3.0) width = Inches(1.75) height = Inches(1.0) shape = shapes.add_shape(MSO_SHAPE.PENTAGON, left, top, width, height) shape.text = 'Step 1' left = left + width - Inches(0.4) width = Inches(2.0) # chevrons need more width for visual balance for n in range(2, 6): shape = shapes.add_shape(MSO_SHAPE.CHEVRON, left, top, width, height) shape.text = 'Step %d' % n left = left + width - Inches(0.4) prs.save('test.pptx') Các hằng số đại diện cho từng hình dạng tự động có sẵn (như mSO_Shape.Rounded_Rect, mso_shape.chevron, v.v.) được liệt kê trên trang loại tự động.autoshape-types page. from pptx import Presentation prs = Presentation() bullet_slide_layout = prs.slide_layouts[1] slide = prs.slides.add_slide(bullet_slide_layout) shapes = slide.shapes title_shape = shapes.title body_shape = shapes.placeholders[1] title_shape.text = 'Adding a Bullet Slide' tf = body_shape.text_frame tf.text = 'Find the bullet slide layout' p = tf.add_paragraph() p.text = 'Use _TextFrame.text for first bullet' p.level = 1 p = tf.add_paragraph() p.text = 'Use _TextFrame.add_paragraph() for subsequent bullets' p.level = 2 prs.save('test.pptx') 7 Ví dụ Enfrom pptx import Presentation from pptx.util import Inches prs = Presentation() title_only_slide_layout = prs.slide_layouts[5] slide = prs.slides.add_slide(title_only_slide_layout) shapes = slide.shapes shapes.title.text = 'Adding a Table' rows = cols = 2 left = top = Inches(2.0) width = Inches(6.0) height = Inches(0.8) table = shapes.add_table(rows, cols, left, top, width, height).table # set column widths table.columns[0].width = Inches(2.0) table.columns[1].width = Inches(4.0) # write column headings table.cell(0, 0).text = 'Foo' table.cell(0, 1).text = 'Bar' # write body cells table.cell(1, 0).text = 'Baz' table.cell(1, 1).text = 'Qux' prs.save('test.pptx') PPTX là viết tắt của cái gì?Một tập tin với. Tiện ích mở rộng tệp PPTX là tệp Microsoft PowerPoint Open XML (PPTX) được tạo bởi Microsoft PowerPoint. Bạn cũng có thể mở loại tệp này với các ứng dụng trình bày khác, như OpenOffice gây ấn tượng, Google Slides hoặc Apple Keynote.Microsoft PowerPoint Open XML (PPTX) file created by Microsoft PowerPoint. You can also open this type of file with other presentation apps, like OpenOffice Impress, Google Slides, or Apple Keynote.
Làm cách nào để tạo một tệp pptx trong python?Tạo một bài thuyết trình.. Bố cục = X. slide_layouts [0] first_slide = X. slide.add_slide (bố cục) # Thêm slide đầu tiên .. FIRST_SLIDE.hình dạng.Tiêu đề.Text = "Tạo PowerPoint bằng Python" First_Slide.Người giữ chỗ [1]..... Đoạn = TextFrame.add_paragraph () đoạn văn.Text = "Đây là một đoạn trong slide thứ hai!". Làm cách nào để đọc một tệp pptx trong python?Thực sự làm việc.. Nhập trình bày từ PPTX (PIP Cài đặt Python-PPTX). cho mỗi tệp trong thư mục (sử dụng mô -đun GLOB). Nhìn vào mọi slide và trong mọi hình dạng trong mỗi slide .. Nếu có một hình dạng với thuộc tính văn bản, hãy in hình dạng.chữ.. PPT và PPTX là gì?Các định dạng tệp PPT và PPTX là các định dạng trình bày Microsoft PowerPoint được hỗ trợ trong tài liệu/sản phẩm y tế. |