KeyError:无+ argparse python 3.xx

main():

parser = argparse.ArgumentParser(description="IVS code")

parser.add_argument("--prod", help="Product to import config for")

parser.add_argument("--wf", help="File to write results to")

parser.add_argument("--ipf", help="IVS product family file") #not in use yet, might keep all ivs product family in same file

args=parser.parse_args()

print (args)


dataDF,keepDF,rulesDF,family_list,level_list,price_override_dict = getInputDataStructures(args)

================================================== ============================


功能

def getInputDataStructures(args):


#Create the price override dictionary

    reader = csv.reader(open(cfg[args.prod]["po"], 'r'), skipinitialspace=True)

   #reader = csv.reader(open(cfg[args.prod]["po"], 'r'), skipinitialspace=True)

    next(reader, None)  # skip the headers

    price_override_dict = {}

    for row in reader:

        cd,cntry,price = row

        price_override_dict[cd+'|'+cntry] = price

================================================== ==================== YAML 文件 -> 集合和杂项:


lvl: "ITEM_CODE,REGIONS,CLUSTERS,SUBCLUSTER,COUNTRY"

kl: Keep.csv

rs: rules.csv

pf: "Sets and Misc"

ps: "-"

pg: Product_Family.csv 

dt: "Sets_Misc.rpt"

po: "priceOverride.csv"

=================================================== ==========================错误输出:


24]: runfile('.../Workspace/CodeFiles/volume_substitution_v3.py', wdir='.../Workspace/CodeFiles')

Reloaded modules: config

Namespace(ipf=None, prod=None, wf=None)

Traceback (most recent call last):


  File "<ipython-input-24-6b4c2ae644d5>", line 1, in <module>

    runfile('.../Workspace/CodeFiles/volume_substitution_v3.py', wdir=.../CodeFiles')



  File ".../Workspace/CodeFiles/volume_substitution_v3.py", line 447, in <module>

    main()


  File ".../Workspace/CodeFiles/volume_substitution_v3.py", line 130, in main

    dataDF,keepDF,rulesDF,family_list,level_list,price_override_dict = getInputDataStructures(args)


我如何运行它或应该提供什么输入来运行这段代码?有什么方法可以使此代码正常工作?


隔江千里
浏览 202回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python