简体   繁体   English

环境变量不更新

[英]environment variables not updating

I am using the dotenv package.我正在使用 dotenv 包。 I had a key that I had saved in my .env file but I updated it to a new key, but my script still outputs the old key.我有一个已保存在 .env 文件中的密钥,但我将其更新为新密钥,但我的脚本仍输出旧密钥。 I have the ".env" file in the root directory.我在根目录中有“.env”文件。

I thought that by using load_dotenv() that it's taking in the new keys whatever they may be at the current state in time and saving it to be used in the script.我认为通过使用 load_dotenv() 它可以及时接收新键的当前状态并将其保存以在脚本中使用。 What am I doing wrong?我究竟做错了什么?

import os
from dotenv import load_dotenv
import praw
load_dotenv()


reddit = praw.Reddit(client_id=os.getenv('reddit_personal_use'),
                     client_secret=os.getenv('reddit_api_key'),
                     user_agent=os.getenv('reddit_app_name'),
                     username=os.getenv('reddit_username'),
                     password=os.getenv('reddit_pw'))

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

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