Created
May 26, 2022 06:15
-
-
Save tkazusa/7dbf550642070232bbb219d534d280de to your computer and use it in GitHub Desktop.
This file contains hidden or 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 argparse | |
def get_args(): | |
parser = argparse.ArgumentParser(description='This is sample argparse script') | |
parser.add_argument('-n', '--name', default='hogehoge', type=str, help='This is name.') | |
parser.add_argument('-a', '--age', default=30, type=int, help='This is age') | |
parser.add_argument('-s', '--sex', default='male', type=str, choices=['male', 'female'], help='This is sex') | |
return parser.parse_args() | |
def main(): | |
args = get_args() | |
print(args) | |
print("name: %s" % args.name) | |
print("age : %d" % args.age) | |
print("sex : %s" % args.sex) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment