Привет. Я пытаюсь создать цикл readline, а затем распечатать его по отдельности в формате, но каждый раз, когда я делаю это, он просто повторяется.вот мой код:
LF = open('fees.txt', 'r')
print('Now the final table\n')
print("Airline", format("1st bag",">15"),format("2nd bag",">15"), \
format("Change Fee",">15"),format("Other Fee",">15"), \
format("Feel Like",">15"),'\n')
line = LF
while line != '':
line = str(line)
line = LF.readline()
line = line.rstrip('\n')
print(line, format(line,'>10'),format(line,'>15'), format(line,'>15'), \
format(line,'>15'), format(line,'>15'),'\n')
LF.close()
print('===================================================\n')
и результат всегда получается так:
Now the final table
Airline 1st bag 2nd bag Change Fee Other Fee Feel Like
Southwest Southwest Southwest Southwest Southwest Southwest
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
Yes! Yes! Yes! Yes! Yes! Yes!
JetBlue JetBlue JetBlue JetBlue JetBlue JetBlue
20 20 20 20 20 20
35 35 35 35 35 35
75 75 75 75 75 75
125 125 125 125 125 125
Yikes Yikes Yikes Yikes Yikes Yikes
Alaska Airlines Alaska Airlines Alaska Airlines Alaska Airlines Alaska Airlines Alaska Airlines
25 25 25 25 25 25
25 25 25 25 25 25
125 125 125 125 125 125
155 155 155 155 155 155
Ooof Ooof Ooof Ooof Ooof Ooof
Delta Delta Delta Delta Delta Delta
25 25 25 25 25 25
35 35 35 35 35 35
200 200 200 200 200 200
150 150 150 150 150 150
We Lost Track We Lost Track We Lost Track We Lost Track We Lost Track We Lost Track
United United United United United United
25 25 25 25 25 25
35 35 35 35 35 35
200 200 200 200 200 200
250 250 250 250 250 250
Whaaaaat? Whaaaaat? Whaaaaat? Whaaaaat? Whaaaaat? Whaaaaat?
Am. Airlines Am. Airlines Am. Airlines Am. Airlines Am. Airlines Am. Airlines
25 25 25 25 25 25
35 35 35 35 35 35
200 200 200 200 200 200
205 205 205 205 205 205
Arrrgh! Arrrgh! Arrrgh! Arrrgh! Arrrgh! Arrrgh!
Spirit Spirit Spirit Spirit Spirit Spirit
30 30 30 30 30 30
40 40 40 40 40 40
100 100 100 100 100 100
292 292 292 292 292 292
Really?? Really?? Really?? Really?? Really?? Really??
===================================================
как мне это исправить, чтобы получилось вот так.
Юго-Запад 0 0 0 0 Да!
Jetblue 20 35 75 125 Yikes!
и т. Д. И т. П.