13 lines
283 B
Python
13 lines
283 B
Python
from pathlib import Path
|
|
|
|
filenames = ['cats.txt', 'dogs.txt']
|
|
|
|
for filename in filenames:
|
|
path = Path(filename)
|
|
try:
|
|
contents = path.read_text()
|
|
except FileNotFoundError:
|
|
pass
|
|
else:
|
|
print(f"\nReading file: {filename}")
|
|
print(contents) |