I'll tell you four ways.
fname = "file path"
#1.
with open(fname) as f:
lines = f.readlines()
#2.
lines = [line.rstrip('\n') for line in open(fname)]
#3.
with open(fname, "r") as ins:
lines = []
for line in ins:
array.append(line)
#4.
lines = tuple(open(fname, 'r'))
© 2024 OneMinuteCode. All rights reserved.