A
A
AkaMaloy2021-07-30 20:12:49
Python
AkaMaloy, 2021-07-30 20:12:49

Readline Reads a line through one, what to do?

with open(r'C:\Users\Users\Downloads\dataset_3380_5.txt', 'r') as url:
for file in url:
file = url.readline().strip().split()
print(file)

Outputs

8 Andrews 166

10 Bishop 175

3 Paterson 136

10 Higgins 167

4 Brown 145 Must

output
6 Andrews 155
8 Andrews 166
5 Porter 147
10 Bishop 175
2 Larkins 129
3 Paterson 136
6 Parkinson 159
10 Higgins 167 8
Farmer 165 174

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-07-30
@AkaMaloy

readline is redundant

with open(r'C:\Users\Users\Downloads\dataset_3380_5.txt', 'r') as url:
    for file in url:
        file = file.strip().split()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question