我有我想分析的数据行。 的数据是这样的:在Python中用分隔符分析行
a score=216 expect=1.05e-06
a score=180 expect=0.0394
我想要做的是有一个子程序 是解析它们和返回值2(得分和期望)为 每一行。
但是我的这个功能似乎并没有工作:
def scoreEvalFromMaf(mafLines):
for word in mafLines[0]:
if word.startswith("score="):
theScore = word.split('=')[1]
theEval = word.split('=')[2]
return [theScore, theEval]
raise Exception("encountered an alignment without a score")
请指点什么是应该做的正确方法?
顺便说一句,从来没有养'Exception',因为这是不可能的三立抓住它随时增加更多的东西窄,像'ValueError'或者是你创建的。 – 2010-06-02 04:29:33