Created
June 30, 2019 05:20
-
-
Save youknowcast/0db15243d1c492244fd58919b6197cb8 to your computer and use it in GitHub Desktop.
challenge1-2 nl.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
args = sys.argv | |
if len(args) < 2: | |
print("usage python nl.py path/to/file") | |
exit() | |
path = args[1] | |
if os.path.exists(path) == False: | |
print("file not found.") | |
exit() | |
i = 1 | |
f = open(path, 'r') | |
while True: | |
s = f.readline() | |
if not s: break | |
if len(s) == 1: | |
print(" \t") | |
else: | |
print("{:6d}\t{}".format(i, s[:-1])) | |
i += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "test nl.py" | |
diff <(nl fizz_buzz.py) <(python nl.py fizz_buzz.py) | wc -l | awk '{$0 == 0 ? m = "ok" : m = "ng"} END {print m}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment