LoginSignup
0
1

More than 1 year has passed since last update.

pythonよく使うコード集

Posted at

この記事について

pythonでコーディングする時に、毎回検索するのが面倒くさいのでまとめる

argparse

import argparse

parser = argparse.ArgumentParser(description='')

parser.add_argument('arg1', help='Config file path')
parser.add_argument('-m', '--make_cert', action='store_true')
parser.add_argument('-x', '--extract', action='store_true')
parser.add_argument('-e', '--embedding', action='store_true')
parser.add_argument('-d', '--dummy_cert', action='store_true')
parser.add_argument(
    '-p',
    '--python_cmd_for_dummy',
    action='store',
    nargs="?",
    default='python',
    type=str,
    help="Python command for running dummy cert tool."
)

args = parser.parse_args()

logging


from logging import getLogger, StreamHandler, Formatter, INFO

logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(INFO)
formatter = Formatter('%(asctime)s - %(levelname)s - %(filename)s - %(message)s')
handler.setFormatter(formatter)
logger.setLevel(INFO)
logger.addHandler(handler)
logger.propagate = False

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1