Windows控制台给python传入字典参数

明明很简单的,害的老子搞了两个多小时?

parser.add_argument("params", default=None, type=None,
                 dest='params', help='need to be implement')

after args=parser.parse_args() is used, send a string params to args.params,
the format is like:
"{'key':value,'key2':"string"}"

then use the code below make the string change to a dict, the apply to the args.params

dict_value = eval(args.params)
args.params = dict_value

  




Le vent se lève! . . . il faut tenter de vivre!


Le vent se lève! . . . il faut tenter de vivre!
原文地址:https://www.cnblogs.com/bai2018/p/14989272.html