開発環境
- OS X Lion - Apple(OS)
- BBEdit - Bare Bones Software, Inc., Emacs(Text Editor)
- プログラミング言語: Python
『初めての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('sample.txt', 'w') as f:
f.write("Hello file world!")
with open('sample.txt') as f:
print(f.read())
入出力結果(Terminal)
$ ls sample.txt ls: sample.txt: No such file or directory $ ./sample.py Hello file world! $ ls sample.txt sample.txt $
0 コメント:
コメントを投稿