I have to replace a key with value in python script and i am reading key from Config file to create a url.
for example:https://xyz/prefix=dcm_accountclick_201903
Config File:
go_req=https://xyz/prefix=dcm_accountclick_,yday_mnth
go_key=yday_mnth,
Script:
yday_date = datetime.datetime.today() - timedelta(days=1)
last_date_fmt = datetime.datetime.strftime(yday_date,'%Y%m%d')
yday_mnth = last_date_fmt[:6]
reqItems = envvars.list['go_req'](here my envars script reads the go_req from config file)
reqKeys = envvars.list['go_key'](here my envars script reads the go_req from config file)
ur= reqItems.split(',')
keys= reqKeys.split(',')
req_url= ''
for i in ur:
for j in keys:
if (str(i) == str(j)):(here if yday_mnth in url matches with key then i will try to add the value which i am generating in script)
req_url += i(here eventhough it matches yday_mnth==yday_mnth am getting output as below)
https://xyz/prefix=dcm_accountclick_yday_mnth
so i am not sure why its not taking the value of the variable yday_mnth and if i give as below then its working however i want my script to be generic.
req_url += yday_mnth