-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFiles.py
More file actions
38 lines (28 loc) · 761 Bytes
/
Files.py
File metadata and controls
38 lines (28 loc) · 761 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
37
38
filename = "fileforpractice.txt"
with open(filename, "r", encoding="utf-8") as file:
content = file.read()
print(content)
fhand = open('fileforpractice.txt')
count = 0
for line in fhand:
count = count + 1
print('Line Count:', count)
fhand.close()
fhand = open('fileforpractice.txt')
inp = fhand.read()
print(len(inp))
fhand.close()
fhand = open('fileforpractice.txt')
for line in fhand:
line = line.rstrip()
# Skip 'uninteresting lines'
if not line.startswith('From'):
continue
# Process our 'interesting' line
print(line)
fout = open('fileforpractice.txt', 'w')
print(fout)
line1 = "This here's the wattle,writing to a file\n"
fout.write(line1)
fhand.close()
fout.close()