展开全部
#!/usr/bin/python
# encoding: utf-8
import re
context = """
0.00000000E+00 1.99000000E-02 1.05000000E+00 0.00000000E+00 3.88519671E+02
4.20000000E-02 1.99000000E-02 1.00800000E+00 0.00000000E+00 4.23216155E+02
8.40000000E-02 1.99000000E-02 9.66000000E-01 0.00000000E+00 4.67920285E+02
1.26000000E-01 1.99000000E-02 9.24000000E-01 0.00000000E+00 4.89975818E+02
1.68000000E-01 1.99000000E-02 8.82000000E-01 0.00000000E+00 5.01845166E+02
2.10000000E-01 1.99000000E-02 8.40000000E-01 0.00000000E+00 5.10017363E+02
2.52000000E-01 1.99000000E-02 7.98000000E-01 0.00000000E+00 5.15927207E+02
2.94000000E-01 1.99000000E-02 7.56000000E-01 0.00000000E+00 5.18914324E+02
3.36000000E-01 1.99000000E-02 7.14000000E-01 0.00000000E+00 5.18683254E+02
"""
patt = re.compile(r"\d\.\d+E[+-]\d{2}")
array = []
for ln in filter(None, context.splitlines()):
array.append(map(float, patt.findall(ln)))
debug = True
def debugView(obj):
import pprint
if debug:
pprint.pprint(obj)
debugView(array)
你的数据来自文本文636f707962616964757a686964616f31333332643337件,可以用 for ln in filter(None, open(datafile, 'rt'))
替代 for ln in filter(None, context.splitlines())