-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCWD-1.py
More file actions
71 lines (60 loc) · 1.96 KB
/
TestCWD-1.py
File metadata and controls
71 lines (60 loc) · 1.96 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
65
66
67
68
69
70
71
print("""Must run the IDE or text editor as adminstrator
to run/edit/save this program/script as/if these files are in C drive
of the computer""")
import os
dirpath = os.getcwd()
print("current directory is : " + dirpath)
foldername = os.path.basename(dirpath)
print("Directory name is : " + foldername)
import os
dirpath = os.getcwd()
print("current directory is : " + dirpath)
foldername = os.path.basename(dirpath)
print("Directory name is : " + foldername)
scriptpath = os.path.realpath(__file__)
print("Script path is : " + scriptpath)
print(""" Reading file all at once """)
fl = open("TEST111.txt", "r+")
print("print the name of the file by print(fl.name)")
print(fl.name)
print("print the mode the file is opened in by print(fl.mode) ")
print(fl.mode)
print(fl.read())
fl.close
print(""" Reading file bit by bit """)
fl1 = open("pagla.txt", "r+")
print("print the name of the file by print(fl1.name)")
print(fl1.name)
print("print the mode the file is opened in by print(fl1.mode) ")
print(fl1.mode)
print(fl1.read(0))
print(fl1.read(1))
print(fl1.read(2))
print(fl1.read(3))
print(fl1.read(4))
print(fl1.read(5))
print(fl1.read(7))
print(fl1.read(9))
fl1.close
print(""" Reading file line by line """)
fl1 = open("pagla.txt", "r+")
print("print the name of the file by print(fl1.name)")
print(fl1.name)
print("print the mode the file is opened in by print(fl1.mode) ")
print(fl1.mode)
print(fl1.readline())
print(fl1.readline())
print(fl1.readline(7))
fl1.close
print(""" also cxan open file by code block -
"with open("pagla.txt", "r+") as fl1:
pass"
the program will autometically close the file when outside
the nblock and if there is any error, the code will exit
and thus close the file, so the file will not be corrupted
""")
with open("pagla.txt", "r+") as fl1:
pass
print("""\nকি কওরীন আআই আপওনীরা
ঊহাট ইস টহিস
ইহা কি ? """)