os.getcwd() vs os.path.abspath(os.path.dirname(__file__))

前端 未结 4 1712
情深已故
情深已故 2020-12-12 19:00

I am using the os module to have relative paths in my Django projects settings.py file. The variable SITE_ROOT is set to the current working directory of the

4条回答
  •  無奈伤痛
    2020-12-12 19:45

    The command os.path.abspath(os.path.dirname(__file__)) returns the directory in which the code file is stored, but os.getcwd() gives you your current working directory which is by default where the code was executed, the latter can be changed using the os.chdir() command.

提交回复
热议问题