12 lines
251 B
Python
12 lines
251 B
Python
from pathlib import Path
|
|
|
|
print("--- Reading in the entire file:")
|
|
path = Path('learning_python.txt')
|
|
contents = path.read_text()
|
|
print(contents)
|
|
|
|
print("\n--- Looping over the lines:")
|
|
lines = contents.splitlines()
|
|
for line in lines:
|
|
print(line)
|