2014年5月17日土曜日

開発環境

Head First Programming A learner's guide to programming using the Python language (David Griffiths(著)、Paul Barry(著)、 O'Reilly Media; )のChapter 5(hashes and databases - Putting data in its place)、Code Manets(p.155)を解いてみる。

Code Manets(p.155)

コード(BBEdit)

sample155,.py

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

scores = {}

with open('results.txt') as result_f:
    for line in result_f:
        name, score = line.split()
        scores[name] = score

for name, score in scores.items():
    print('Sufer {0} scored {1}'.format(name, score))

入出力結果(Terminal)

$ ./sample155.py
Sufer Stacey scored 7.81
Sufer Aaron scored 8.31
Sufer Johnny scored 8.65
Sufer Zack scored 7.21
Sufer Joseph scored 8.45
Sufer Aideen scored 8.05
Sufer Juan scored 9.12
$

0 コメント:

コメントを投稿