Home  >  Q&A  >  body text

selenium-selenium-webdriver - python adds the current directory to the environment variable

python gets the script execution directory and adds it to the environment variable,

Because there is a driver chromedriver.exe in the current directory,

You need to use after the python

script
dir_path = sys.path[0]

The current script execution directory already exists. How to add it to the environment variable later?

Is it executed using cmd of python?

python It’s my first time using it. I hope python can give me some guidance

習慣沉默習慣沉默2676 days ago987

reply all(1)I'll reply

  • typecho

    typecho2017-06-22 11:54:22

    There are two methods,
    The first is to use the sys.path.append() method to add the current directory to the directory list searched by the module, such as sys.path.append(dir_path)
    The second is to The path of the current directory is added to the system’s PYTHONPATH environment variable.

    reply
    0
  • Cancelreply