Skip to content

Commit f0dc6b0

Browse files
committed
wc: byte count
1 parent 466c007 commit f0dc6b0

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

  • implement-shell-tools/wc

implement-shell-tools/wc/wc.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@
1313
bytes = 0
1414

1515
dict = {}
16+
adict = {}
1617

1718
for file in args.path:
1819
f = open(file)
19-
# text = []
20-
# text.append(f.read().split("\n"))
21-
# print(f.read().split("\n"))
2220
dict[file] = f.read().split("\n")
23-
# print(dict)
21+
adict[file] = f.read()
22+
23+
for file in args.path:
24+
f = open(file)
25+
adict[file] = f.read()
26+
2427
for f in dict:
2528
word_per_line = 0
2629
byte_per_line = 0
27-
for l in dict[f]:
30+
for l in adict[f]:
2831
word_per_line += len(l.split())
2932
byte_per_line += len(l.encode("utf-8"))
30-
# print(byte_per_line)
31-
print(str(len(dict[f]) - 1) + " " + str(word_per_line) + " " + f)
32-
33+
print(" " + str(len(dict[f]) - 1) + " " + str(word_per_line) + " " + str(byte_per_line) + " " + f)

0 commit comments

Comments
 (0)