Passing Directory To Python Script As Command Line Argument
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 ru
Solution 1:
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')
Post a Comment for "Passing Directory To Python Script As Command Line Argument"