How to print a file to stdout?

Sure. Assuming you have a string with the file’s name called fname, the following does the trick.

with open(fname, 'r') as fin:
    print(fin.read())

Leave a Comment