-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4.py
More file actions
20 lines (18 loc) · 706 Bytes
/
Copy path4.py
File metadata and controls
20 lines (18 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'''
> Date Created: 31/07/2025
> Author: Ishaan Rastogi
> Purpose: To read a file and print its content line by line.
> Operating System: This is only for Windows OS, it may or may not work on other OS
> Program Status: 100% Working
'''
# Since we are using a relative path here, use r before the string to avoid escape sequence issues
f = open(r"Code With Harry\9. File IO\file.txt") # By default, the file is opened in read mode
line = f.readline()
while ( line != ""):
print(line, end='') # Print the line without adding an extra newline
line = f.readline() # Read the next line
f.close() # Close the file to free up resources
'''
Terminal - Ctrl + Shift + `
> python "path to the file"
'''