【发布时间】:2013-08-04 05:01:46
【问题描述】:
我如何使用 enemerate 或其他一些函数在我输入到 python 的整个字符串的 txt 文件中返回这些值
TW11 42.83 -72.94 2.1
TW22 41.727 -75.81 3.9
我目前的工作是
in_file =open('tow.txt','r')
for line in_infile:
L=line.strip().split()
Tower = L[0]
Lat = L[1]
Long = L[2]
ComDis = L[3]
print (Tower,Lat,Long,ComDis)
但是我只能返回输入文件的第一行,文件中大约有 20 行只是想举一个简短的例子
【问题讨论】:
标签: python string split int strip