first, read the file into a string line by line; then convert the string to a variable. In python, you can do the following
i = 0
with open("file.txt", "r") as ins:
v = "var"+str(i)
for line in ins:
exec(v+"='str(line)'")
i+=1
another approach is to read the lines into a list:
with open("file_name.txt", "r") as f:
line_list = []
for line in f:
line_list.append(line)
your first line can be accessed in line_list[0], and second line in line_list[1] and so on
7
solved How do I make each line from a file list into separate variables?