这可能太基础了,但是无论如何我还是要问!
我正在寻找一种获取包含我的比赛的字段号的方法,以便根据结果执行更多工作。
我尝试过类似的事情:
with open(filename) as f:
for line in f:
for field in range(-1,-1): # Wrong --> How can I decrement starting from the last field backwards to the 1st field in each line of a file?
if pattern in field:
print("field# " + field + " shows:" + line.split(' ')[field])
谢谢!
-史蒂夫