Is there a one-liner to read all the lines of a file in Python, rather than the standard:
f = open(\'x.txt\') cts = f.read() f.close()
Seems li
Starting in Python 3.5, you can use the pathlib module for a more modern interface. Being Python 3, it makes a distinction between reading text and reading bytes:
pathlib
from pathlib import Path text_string = Path('x.txt').read_text() # type: str byte_string = Path('x.txt').read_bytes() # type: bytes