Question:
I want to detect the lines in a file using Python though I can’t. I don’t want to use readlines
because it adds \n
to the end of some lines.
Repl link:
f = open(‘file’).readlines()
Question:
I want to detect the lines in a file using Python though I can’t. I don’t want to use readlines
because it adds \n
to the end of some lines.
Repl link:
f = open(‘file’).readlines()
with open('your_file.txt', 'r') as file:
lines = file.read().splitlines()
for line in lines:
print(line)
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.