I am new to python and trying to pass the three variables in to the python script with the below command line..!
$ python C:\test.py --var_name1=cityname --ds_name2="state.sas7bdat" --path="C:\"
Below is the script that I use..
import re
import sys
args = {}
args['pythonFile'] = sys.argv[0]
for arg in sys.argv[1:]:
variable = re.search('\-\-(.*)\=',arg)
variable = variable.group(1)
value = re.search('\=(.*)',arg)
value = value.group(1)
args[variable] = value
print(args)
args prints
{'pythonFile': 'C:\test.py', 'var_name1'='cityname', 'ds_name2'='state.sas7bdat', 'path'='C:\'
Now, how would like to use var_vame1
, ds_name
, path variables in the python script?
for example..
I want to use..
filename=<PATH><DS_NAME>
how do I call these variables in the script? Appreciate your help.