-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_handling(3).py
More file actions
49 lines (43 loc) · 1.1 KB
/
file_handling(3).py
File metadata and controls
49 lines (43 loc) · 1.1 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
"""file handling"""
# file=open("file-name.extension","mode")
'''
r-read
w-write
append-a
+->read and write
'''
# file=open("regex.txt","w")
# file.write("welcome too regex")
# file.close()
# file=open("regex.txt","r")
# content=file.read()
# print(content)
# file.close()
# file=open("ragex.txt","a")
# file.write("append in the regex")
# file.close()
''''''
# file=open("regex2.txt","a")
# file.write("""i am inside regex2 file
# hyy
# this is a
# hello""")
# file.close()
"""autoclose with """
# with open("regex.txt","r") as source,open("regex2.txt","a") as dastination:
# for line in source:
# destination.write("\n"+line)
# with open("regex.txt","r") as source, open("regex2.txt","r") as destination:
# context1=source.read()
# context2=destination.read()
# print(context1)
# print(context2)
# with open ("regex2.txt","r") as file:
# count_char=0
# count_str=0
# for line in file:
# ch=line.split()
# count_str+=1
# for i in line:
# count_char+=1
# print(count_char,count_str)