-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment #9.py
More file actions
31 lines (27 loc) · 873 Bytes
/
Assignment #9.py
File metadata and controls
31 lines (27 loc) · 873 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
'''
Lawrence Woods
2/18/2018
Assignment #9
Using os.walk, write a script that will print the filenames of zero length files. It should also print
the count of zero length files.
Write a script that will list and count all of the images in a given HTML web page/file. You can assume that:
Each image file is enclosed with the tag <img and ends with >
The HTML page/file is syntactically correct
'''
import os
count = 0
for root, dirs, files in os.walk(".", topdown = False):
for name in files:
if os.path.getsize(name) == 0:
print(name)
count = count + 1
print("Number of files with zero length:",count)
count = 0
try:
file = open("sample.html","r")
for line in file:
if "<img" in line:
count = count + 1
print("Number of images:",count)
except:
print("Error opening file")