我是python的新手。我的意思是全新的,我必须从txt文件中提取并打印(或保存在txt中)第8列的值,如下所示:
PDE 1980 01 01 020925.70 36.21 -120.85 5 3.2 MLBRK ...... .......
所以基本上,对于每一行,我只需要选择' 3.2' ..
到目前为止,我有:import sys
import numpy
text_file = open("earthquake_catalog_example.txt", "r")
lines = text_file.read().split(',')
Value1, Value2, Value3, Value4, Value5, Value6, Value7, Magnitude, Value9, Value10, Value11, Value12 = lines.split(" ")
Value1 = str(Value1)
Value2 = float(Value2)
Value3 = float(Value3)
Value4 = float(Value4)
Value5 = float(Value5)
Value6 = float(Value6)
Value7 = float(Value7)
Magnitude = float(Magnitude)
Value9 = float(Value9)
Value10 = str(Value10)
Value11 = str(Value11)
Value12 = str(Value12)
print lines
print len(lines)
但收到错误:' list'对象没有属性' split'
感谢