開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの無料機能制限版、light版)
- Script言語: Python
『初めてのPython 第3版』(Mark Lutz 著、夏目 大 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-393-7) のII部(ビルトインオブジェクト)のまとめ演習11(ファイル)を解いてみる。
その他参考書籍
11.
コード(TextWrangler)
sample.py
#!/usr/bin/env python3.3 #-*- coding: utf-8 -*- file = open("myfile.txt", "w") file.write("Hello file world!") file.close()
sample1.py
#!/usr/bin/env python3.3 #-*- coding: utf-8 -*- file = open("myfile.txt") print(file.read()) file.close()
入出力結果(Terminal)
$ ./sample.py $ ./sample1.py Hello file world! $ ls -l myfile.txt -rw-r--r-- 1 kamimura staff 17 11 7 14:09 myfile.txt $
0 コメント:
コメントを投稿