pydotenv.py 文件源码

python
阅读 40 收藏 0 点赞 0 评论 0

项目:Dockerfiles 作者: appscode 项目源码 文件源码
def get_key(dotenv_path, key_to_get):
    """
    Gets the value of a given key from the given .env

    If the .env path given doesn't exist, fails
    """
    key_to_get = str(key_to_get)
    if not os.path.exists(dotenv_path):
        warnings.warn("can't read %s - it doesn't exist." % dotenv_path)
        return None
    dotenv_as_dict = dotenv_values(dotenv_path)
    if key_to_get in dotenv_as_dict:
        return dotenv_as_dict[key_to_get]
    else:
        warnings.warn("key %s not found in %s." % (key_to_get, dotenv_path))
        return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号