開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
Learning Python (Mark Lutz (著)、Oreilly & Associates Inc)のPART Ⅱ.(Types and Operations)、Chapter 9.(Tuples, Files, and Everything Else)、Test Your Knowledge: Quiz 4.を解いてみる。
その他参考書籍
Test Your Knowledge: Quiz 4.
コード(BBEdit)
sample4.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import pickle
d = dict(a=1, b=2, c=3, d=4, e=5)
print(d)
with open('sample4.pkl', 'wb') as f:
pickle.dump(d, f)
with open('sample4.pkl', 'rb') as f:
a = pickle.load(f)
print(a)
入出力結果(Terminal, IPython)
$ ./sample4.py
{'d': 4, 'e': 5, 'b': 2, 'c': 3, 'a': 1}
{'c': 3, 'e': 5, 'b': 2, 'd': 4, 'a': 1}
$
0 コメント:
コメントを投稿