看起来像是正则表达式的作业。
像[0-9][.][0-9]*这样的东西应该能做到。
蟒蛇:
import re import numpy as np line = 'TM-score= 0.36068 (if normalized by length of Chain_2)' str = re.search(r'[0-9][.][0-9]*', line) number1 = float(str.group(0)) print(number1)