私の問題は、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()