3:16 PM 16-Jan-22
files:
storing data:
Creating and storing data into the file:
with open("greet.txt", "w") as f:
( file can be rewritten if data already exists in the file )
Reading from the file:
with open("greet.txt", "r") as f:
text_of_file = f.read()
Appending a file to already existing file:
with open("greet.txt", "a") as f:
f.write("\nHave a nice day!")
with open("greet.txt") as f:
message = f.read()
print(message)
No comments:
Post a Comment