Skip to content

Commit a35d975

Browse files
committed
implement basic wc
1 parent b9dc023 commit a35d975

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

  • implement-shell-tools/wc

implement-shell-tools/wc/wc.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import argparse
2+
3+
parser=argparse.ArgumentParser(prog="wc",usage="implement a simple wc in python")
4+
parser.add_argument("path",nargs="+")
5+
args=parser.parse_args()
6+
7+
print(args.path)
8+
paths=args.path
9+
for path in paths :
10+
with open(path,"r") as f :
11+
lines=f.readlines()
12+
print(len(lines) , path)

0 commit comments

Comments
 (0)