-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.py
More file actions
28 lines (22 loc) · 651 Bytes
/
Copy pathMain.py
File metadata and controls
28 lines (22 loc) · 651 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import time #needed for sleep()
import os #needed to delete file
#Files Directory
file = ("C:\\Users\Owner\Desktop\openme.txt")
print ("Opening...", file)
time.sleep(2)
#Settings file to be writtable and openable
#Open & Write
x = open(file,"w")
x.write("Sucessfully wrote") #you can change this to anything you want
#Settings file to be readable and printable
#Read
x = open(file,"r")
print(x.read())
x.close()
#Delete
if os.path.exists("C:\\Users\Owner\Desktop\openme.txt"):
os.remove("C:\\Users\Owner\Desktop\openme.txt")
else:
print("The file does not exist")
#create new file
x = open("C:\\Users\Owner\Desktop\newfile.txt","x")