forked from Shwetha-Kalavara/Python_Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiles_modes.py
More file actions
64 lines (34 loc) · 1.16 KB
/
Copy pathfiles_modes.py
File metadata and controls
64 lines (34 loc) · 1.16 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# without context manager
path = r"C:\Users\Vidyashree M C\PycharmProjects\Alpha4\files\sample.txt"
# file = open(path)
# print(file)
# print(file.closed) # False
# file.close()
# print(file.closed) # True
# with context manager
import os
os.chdir(r"C:\Users\Vidyashree M C\PycharmProjects\Alpha4\files")
# with open("sample.txt") as file:
# print(file)
# print(file.mode)
# print(file.name)
# print(file.readable())
# print(file.writable())
# print(file.closed) # False
# print(file.closed) # True
###################################################################
# with open("sample.txt", "w") as file:
# print(file)
# print(file.readable())
# print(file.writable())
# with open("sample.txt", "a") as file:
# print(file)
# print(file.writable())
# os.remove("sample1.txt")
# with open("sample1.txt", "x") as file:
# print(file.readable())
# print(file.writable())
# with open("sample.txt", "r+") as file:
# print(file.writable())
# print(file.readable())
#############################################################