我的问题是,在 python 第一次读取原始输入之后,它随后不再正确读取输入。我已经尝试了很多东西,但我似乎无法得到它。我究竟做错了什么?
file_path = 'C:\\Users\\Neo\\My Documents\\Python Scripts\\FTC Scouting\\sample.txt'
file = open(file_path, 'r')
Team_Numbers = []
tNum = 'Team Number: '
tName = 'Name: '
ui = ''
def list_teams(n):
count = 0
if n == '1':
for line in file:
check = line.find(tNum)
if not check == -1:
print line[len(tNum):] #prints everything after the Team Number:
count += 1
elif n == 2:
for line in file:
check = line.find(tName)
if not check == -1:
print line[len(tName):] #prints everything after the Team Number:
count += 1
while not ui == 'end':
ui = raw_input('1: to list Team Numbers\n2: to list Names\n')
list_teams(ui)
file.close()