readlines as string python code example
Example 1: python read file to variable
with open('data.txt', 'r') as file:
data = file.read().replace('\n', '')
Example 2: readlines from file python
f = open("file.txt", 'r')
print(f.readlines()) # array of file lines