I am trying to pass a particular directory to a python script and later use that directory in the script . the Directory can be located anywhere. for example, the script should run on the command line as
script.py directory_name
So far I looked but nothing as such.
You can do it as:
directory_name=sys.argv[n]
It is always good to catch the error, if directory name is not provided by the user.
import sys ... ... try: directory_name=sys.argv[1] print(directory_name) except: print('Please pass directory_name')
check the sys.argv here
import sys print sys.argv[1]# this gives directory name