It is better to handle this with “with” to close the descriptor automatically for you. This will work with both 2.7 and python 3.
with open('/path/to/my/file.txt', 'r') as f:
print(f.read())
It is better to handle this with “with” to close the descriptor automatically for you. This will work with both 2.7 and python 3.
with open('/path/to/my/file.txt', 'r') as f:
print(f.read())