擅长:python、mysql、java
<p>我想我们可以用标准库函数来解决你的问题</p>
<p>只是友好的提示:</p>
<p>这三条线</p>
<pre><code>first=[row[0] for row in data]
rownum1=[row[1] for row in data]
rownum2=[row[2] for row in data]
</code></pre>
<p>将执行3 x 10.000循环,最好在每行读取数据时执行拆分</p>
<p>请按照@0O0O0O0请求复制粘贴错误</p>
<pre><code>try:
text_file = open("list_number.txt", "r") #File contain your 5 line data, with header removed
try:
count = 0
for row in text_file:
col = row.split() # switch to row.split(',') if you're using coma delimiter
count+=1
if abs(float(col[1]) - float(col[2])) <= 10: # Change to 1
#print('The values in row %s are %s and %s, are within 10.0 of each other.' % (count, col[1], col[2]))
print('The values in row {0} are {1} and {2}, are within 10.0 of each other.'.format(count, col[1], col[2]))
finally:
text_file.close()
except IOError as e:
print("Unable to open file : ", e)
</code></pre>