简体   繁体   English

.env 文件中的当前路径变量

[英]Current Path variable in .env file

Is there a way to refer to the current directory in a .env file?有没有办法在.env文件中引用当前目录?

Trying to point the location of a config file from userprofile, to the current path.试图将配置文件的位置从用户配置文件指向当前路径。 For example,例如,

CONFIG_FILE=${USERPROFILE}\.configs\config.cfg

I would like to set it to,我想将它设置为,

CONFIG_FILE=${CURRENTPATH}\.configs\config.cfg

Running my program w/ pipenv on Ubuntu, I'm able to do eg:在 Ubuntu 上使用 pipenv 运行我的程序,我可以执行以下操作,例如:

SETUP_CFG=${PWD}/setup.cfg

And in Python I can do:在 Python 中我可以做到:

import os
from pathlib import Path

assert os.environ.get("SETUP_CFG") == (Path.cwd() / "setup.cfg").as_posix()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM