I\'ve searched and I can only find questions about the other way around: writing stdin to a file :)
Is there a quick and easy way to dump the contents of a file to s
If you need to do this with the pathlib module, you can use pathlib.Path.open() to open the file and print the text from read()
:
from pathlib import Path
fpath = Path("somefile.txt")
with fpath.open() as f:
print(f.read())
Or simply call pathlib.Path.read_text():
from pathlib import Path
fpath = Path("somefile.txt")
print(fpath.read_text())
My shortened version in Python3
print(open('file.txt').read())