File IO
How to open a file
# Syntax:
my_file = open('<location_to_file>/<file_name>')To read that file:
content = myfile.read()
# To print the content
print(content)Particular read case
content = myfile.read()
data = myfile.read()
print(content)
print(data)Why does this happen?
To reset the cursor:
Add each line of file to a list:
Closing the file:
Another way of opening a file is with the with clause:
with clause:Last updated