2013年2月11日月曜日

開発環境

『初めてのPython 第3版』(Mark Lutz 著、夏目 大 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-393-7) のII部(ビルトインオブジェクト)のまとめ演習11.(ファイル)を解いてみる。

その他参考書籍

11.(ファイル)

コード(BBEdit)

sample.py

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

with open('myfile.txt', 'w') as f:
    f.write("Hello file world!")

with open('myfile.txt') as f:
    print(f.read())

入出力結果(Terminal)

$ ./sample.py
Hello file world!
$ ls myfile.txt
myfile.txt
$

0 コメント:

コメントを投稿