現(xiàn)如今有一組新的秒表數(shù)據(jù),需要對其數(shù)據(jù)進(jìn)行提取
sarah.txt
sara,2002-9-9,2:58,2.58,2:39,2-25,2-55,2:54,2.18,2:55,2:55
1.將sarah.txt中的名字與成績打印出來(使用讀取文件的方式)
#coding=utf-8#打印出秒表數(shù)據(jù)的姓名與前三列的成績def get_file(filename): try: with open(filename) as f: data=f.readline().strip().split(",") return data except IOError as e: raise edef qxsj(time_string): if "-" in time_string: splitter="-" elif ":" in time_string: splitter=":" else: return time_string (fen,miao)=time_string.strip().split(splitter)