Created
October 10, 2019 15:56
-
-
Save max747/146e709a4665eee3e4361ed2821d408d to your computer and use it in GitHub Desktop.
Python でコマンドラインスクリプトを書くときのテンプレート
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
#!/usr/bin/env python3 | |
""" | |
概要 | |
""" | |
import argparse | |
import logging | |
logging.basicConfig(level=logging.INFO) | |
logger = logging.getLogger(__name__) | |
def main(args): | |
# ... | |
def parse_args(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--input', type=argparse.FileType('r'), default=sys.stdin) | |
parser.add_argument('--output', type=argparse.FileType('w'), default=sys.stdout) | |
# ... | |
return parser.parse_args() | |
if __name__ == '__main__': | |
main(parse_args()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment