Skip to content

Commit 1168646

Browse files
committed
Level 4: Lorem Ipsum: pathlib
1 parent f689a6c commit 1168646

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Level_04/loremipsum.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env python3
22

3-
lorem_ipsum = open("loremipsum.txt", "r")
4-
text = lorem_ipsum.read() # type: str
5-
lorem_ipsum.close()
3+
from pathlib import Path
4+
5+
lorem_ipsum = Path("loremipsum.txt")
6+
text = lorem_ipsum.read_text() # type: str
67

78
orig = text
89
text = text.upper()
@@ -14,6 +15,5 @@
1415
print("****************")
1516
print(text)
1617

17-
lorem_ipsvm = open("loremipsvm.txt", "w")
18-
lorem_ipsvm.write(text)
19-
lorem_ipsvm.close()
18+
lorem_ipsvm = Path("loremipsvm.txt")
19+
lorem_ipsvm.write_text(text)

0 commit comments

Comments
 (0)