開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python (プログラミング言語)
Head First Python (Paul Barry(著)、 O'Reilly Media )のChapter 5(Comprehending data: Work that data)、EXERCISE(p.141)を解いてみる。
EXERCISE(p.141)
コード(BBEdit)
sample141.py
#!/usr/bin/env python3 #-*- coding: utf-8 -*- with open('james.txt') as f: james = f.readline().strip().split(',') with open('sarah.txt') as f: sarah = f.readline().strip().split(',') with open('julie.txt') as f: julie = f.readline().strip().split(',') with open('mikey.txt') as f: mikey = f.readline().strip().split(',') print(james, sarah, james, mikey, sep='\n')
入出力結果(Terminal)
$ ./sample141.py ['2-34', '3:21', '2.34', '2.45', '3.01', '2:01', '2:01', '3:10', '2-22'] ['2:58', '2.58', '2:39', '2-25', '2-55', '2:54', '2.18', '2:55', '2:55'] ['2-34', '3:21', '2.34', '2.45', '3.01', '2:01', '2:01', '3:10', '2-22'] ['2:22', '3.01', '3:01', '3.02', '3:02', '3.02', '3:22', '2.49', '2:38'] $
0 コメント:
コメントを投稿