Last active
February 4, 2019 19:04
-
-
Save Robofied/abfc415327c48dc05e11e539c5fbad6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('file1.txt','r') as f: | |
## It will print each line and make the pointer to point at next line. | |
print(f.readline()) | |
## It is telling the current position of the pointer | |
print(f.tell()) | |
## Using seek we can modify the current pointer by passing the position as paramter in seek. | |
f.seek(0) | |
## Checking if pointer comes to 0 or not. | |
print(f.tell()) | |
## Printing out the line again to check what will it prints. | |
print(f.readline()) | |
#[Output]: | |
1. "My name is XYZ". | |
2 | |
1 | |
0 | |
1. "My name is XYZ". | |
with open('file1.txt','r') as f: | |
print(f.readlines()) | |
#[Output]: | |
['1. "My name is XYZ".n', '2. "Currently I am persuing Bachelor's of Technology".n', '3. "I have done several projects on Software Development".'] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment