2015年2月7日土曜日

開発環境

  • OS X Yosemite - Apple (OS)
  • Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
  • Python 3.4 (プログラミング言語)

Introducing Python: Modern Computing in Simple Packages(Bill Lubanovic (著)、 O'Reilly Media)のChapter 8(Data Has to Go Somewhere)、Things to Do 8.3.を解いてみる。

Things to Do 8.3.

コード(Eacs, BBEdit)

sample3.py

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

text = '''author,book
J R R Tolkien,The Hobbit
Lynne Truss,"Eats, Shooots & Leaves"'''

with open('books.csv', 'w') as f:
    print(text, file=f, end='')

入出力結果(Terminal, IPython)

$ ./sample3.py
$ cat books.csv 
author,book
J R R Tolkien,The Hobbit
Lynne Truss,"Eats, Shooots & Leaves"$ 

0 コメント:

コメントを投稿