Skip to content

Instantly share code, notes, and snippets.

@Robofied
Created February 4, 2019 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Robofied/1c912a8db263d0a9eb74b05ef086ae01 to your computer and use it in GitHub Desktop.
Save Robofied/1c912a8db263d0a9eb74b05ef086ae01 to your computer and use it in GitHub Desktop.
## Here opening the file with "with" keyword and it will automatically close the file after before coming out of the with.
with open('file1.txt','r') as f:
print(f.read())
#[Output]:
1. "My name is XYZ".
2. "Currently I am persuing Bachelor's of Technology".
3. "I have done several projects on Software Development".
## Checking if file is closed.
print(f.closed)
#[Output]:
True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment