-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path23.filehandling.py
More file actions
37 lines (28 loc) · 837 Bytes
/
23.filehandling.py
File metadata and controls
37 lines (28 loc) · 837 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
29
30
31
32
33
34
35
36
# filhandling
# creat / open / read / write / delte / close
'''
open()
r = read
a = create / read
w = write
x = create / write
t = text
b = binary / muldi media files image
'''
demofile = open('C:/xampp/htdocs/htmldemo/full-python-course-2020/demo.txt','r')
# print('\n\n',demofile.read())
# read speicific part of file
print('\n',demofile.read())
# file write
writeFile = open('C:/xampp/htdocs/htmldemo/full-python-course-2020/demo.txt','a')
writeFile.write('\nHello New python version 3.0')
writeFile.close()
# creat new file x/a/w
# creatNewFile = open('C:/xampp/htdocs/htmldemo/full-python-course-2020/vivek.txt','w')
# delete a file
import os
deleteFile = os.remove('C:/xampp/htdocs/htmldemo/full-python-course-2020/vivek.txt')
if deleteFile == None:
print('File delte successfully')
else:
print('File not exists')