Hello , I'm yuechuang .
Blog launch :https://bornforthis.cn/posts/19.html
Sometimes you need to store sensitive information in your code , For example, password or API secret key , And in the Python The simplest way to do this is to use os and dotenv modular .
So , You need to install dotenv modular , and os Module is standard Python modular , No installation required .
On the command line , Input :
pip install python-dotenv
Or for Python 3
pip3 install python-dotenv
hypothesis .env
The contents of the file are :
API_KEY="abcd123"
A good practice is to include a in your project .env
file , It contains examples of each secret variable you are using . The contents of this document are as follows :
API_KEY="abcd123"
To load it into your python In file , You should :
import os
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv("API_KEY")
Good! Now? , You are hiding data correctly !
python中matplotlib中問題:Attribute