2016年7月7日木曜日

開発環境

Automate the Boring Stuff with Python (Al Sweigart (著)、No Starch Press)のPart 2.(Automating Tasks)、Chapter 13.(Working with PDF and word Documents)、Practice Projects(Custom Invitations as Word Documents)(No. 7837)を取り組んでみる。

Practice Projects(Custom Invitations as Word Documents)(No. 7837)

コード(Emacs)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import docx

doc = docx.Document()

with open('guests.txt') as f:
    for line in f:
        doc.add_paragraph(line)
        doc.add_page_break()

doc.save('custom_invitations.docx')

入出力結果(Terminal, IPython)

$ ./custom_invitations.py 
$ ls custom_invitations.docx 
custom_invitations.docx
$

0 コメント:

コメントを投稿