Why is the first element in python's sys.path an empty string?

前端 未结 3 1111
孤城傲影
孤城傲影 2020-12-06 05:34

I noticed, when I launch python REPL and do:

import sys
print(sys.path)

The first element of the list is an empty string. This

3条回答
  •  孤城傲影
    2020-12-06 06:05

    sys.path[0] is an entry created by the Python executable to refer to the directory of the script being run. If no script is being run, e.g. the REPL has been invoked directly, an empty entry representing the current directory is added.

提交回复
热议问题