Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def write_file():
- print("Writing a file..")
- try:
- f = open("my_file.txt", "a")
- for num in range(100):
- f.write("Line " + str(num) + "\n")
- f.close()
- except Exception:
- print("Could not write to file")
- def read_file():
- print("Now reading the file..")
- try:
- f = open("my_file.txt", "r")
- for line in f.readlines():
- print(line)
- f.close()
- except Exception:
- print("Could not read to file")
- write_file()
- read_file()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement