python argparser,参数执行函数

python argparser, argument executing function

我想知道如何在 python 中仅调用一个参数来执行 运行 该命令时的函数,例如,

parser = argparse.ArgumentParser(description="Database accounts manager")
parser.add_argument("-s", "--show", help="Shows all database rows and columns", dest="show",required=False)

args = parser.parse_args()

if args.show:
     print("i am beautiful")

what i would like is to when i call this file : python file.py -s or python file.py --show, i would like it to execute a function like i wrote for an example : "print("i am beautiful")

因为当我这样做时我需要给出一个参数以便它执行函数:"print(...)"

给参数添加动作:

parser.add_argument("-s", "--show", help="Shows all database rows and columns", dest="show",required=False, action="store_true")