目的 : 读取一段数据中某一段的数字
import string
def DemoExtensometerArray():
f = open (r'E:\book\Python\data.txt')
tts =[]
lls =[]
ees = []
pps = []
while True:
line = f.readline()
if not line : break
stringlist = line.split(",")
ees.append(float(stringlist[2])/1000.0)
f.close()
return ees
if __name__ == '__main__':
listarray = DemoExtensometerArray()
for eachnum in listarray:
print eachnum
data.txt的数据类似如下:
0.168,62.496,0.00019,0.000
0.200,62.496,0.00019,0.000
0.234,62.496,0.00019,0.000
0.234,62.496,0.00019,0.000
0.301,62.496,0.00019,0.000
0.335,62.496,0.00019,0.000
0.367,64.043,0.00016,0.000
0.402,79.386,0.00019,0.002
0.434,114.380,0.00019,0.004
0.469,151.253,0.00023,0.006
0.501,188.126,0.00031,0.007
0.536,212.203,0.00035,0.009
0.568,225.970,0.00035,0.011
0.600,251.896,0.00039,0.012
0.635,283.159,0.00042,0.014
0.667,316.272,0.00046,0.015
0.701,358.786,0.00058,0.017
0.734,403.786,0.00062,0.019
0.734,403.786,0.00062,0.019
0.767,449.756,0.00066,0.020
运行之后 显示的结果
>>>
1.9e-07
1.9e-07
1.9e-07
1.9e-07
1.9e-07
1.9e-07
1.6e-07
1.9e-07
1.9e-07
2.3e-07
3.1e-07
3.5e-07
3.5e-07
3.9e-07
4.2e-07
4.6e-07
5.8e-07
6.2e-07
6.2e-07
6.6e-07
>>>