Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.55 KB | None | 0 0
  1. import time, datetime
  2. def rAccessFile(file):  ##Opens a file to write in to, then closes
  3.     what = input("What do you want to do with this file? \nREAD\nWRITE\nOVERWRITE\nCLOSE").lower()
  4.     if what.startswith("r"):
  5.         file1 = open(file, "a+")
  6.         print("Below are the files contents.\n" + file1.read())
  7.         file1.seek(0)
  8.         print(file1.read())
  9.         time.sleep(3)
  10.         what = input("What do you want to do now? \nREAD\nWRITE\nOVERWRITE\nCLOSE").lower()
  11.     if what.startswith("w"):
  12.         file1 = open(file, "a+")
  13.         wtw = input("What would you like to add to the file?\n")
  14.         file1.write("\n" + wtw + "\n")
  15.         file1.seek(0)
  16.         print("Below are the files new contents.\n" + file1.read())
  17.         print(file1.read())
  18.         time.sleep(3)
  19.         what = input("What do you want to do now? \nREAD\nWRITE\nOVERWRITE\nCLOSE").lower()
  20.     if what.startswith("o"):
  21.         file1 = open(file, "w+")
  22.         print(file1.read())
  23.         wtw = input("What would you like to write in the file?")
  24.         file1.write(wtw + "\n")
  25.         print("Below are the files new contents.", file1.read())
  26.         what = input("What do you want to do now? \nREAD\nWRITE\nOVERWRITE\nCLOSE").lower()
  27.     if what.startswith("c"):
  28.         print("Goodbye!")
  29. print("Which file would you like to access?\n (If the file doesn't exist, it will be created with whatever name you type.)")
  30. time.sleep(1)
  31. f2a = input(">>>")
  32. if ".txt" in f2a:
  33.     rAccessFile(f2a)
  34. else:
  35.     print("I want to see this")
  36.     f2a.join(f".txt")
  37.     rAccessFile(f2a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement