-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_handling1.py
More file actions
28 lines (23 loc) · 824 Bytes
/
file_handling1.py
File metadata and controls
28 lines (23 loc) · 824 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
with open("demofile.txt","w+")as t:
print(t.write("Hello, welcome to the world of Python"))
# print(t.seek(0))
print(t.read())
# print(len(t))
# f=open("demofile.txt","r")
# import os
# print(os.getcwd())
# import os
# # Specify the directory
# directory = "c:/VS files/Python/specific_directory"
# # Ensure the directory exists
# if not os.path.exists(directory):
# os.makedirs(directory)
# # Specify the full path to the file
# file_path = os.path.join(directory, "demofile.txt")
# # Open the file in the specified directory
# with open(file_path, "w+") as txtfile:
# print(txtfile.write("Hello, welcome to the world of Python"))
# txtfile.seek(0) # Move the cursor to the beginning of the file
# print(txtfile.read())
# # Print the current working directory
# print(os.getcwd())