How can i not show the login ID and password in the python script?
Is there any library or command can I hide those information?
For example:
login_id = "secret_id" instead of login_id = "[email protected]"
password = "secret_password" instead of password = "1234ABCD"
CodePudding user response:
Maybe put the information in a text file, and read the text file into your python script?
with open('credentials.txt') as f:
lines = f.readlines()
login_id = lines[0].strip()
password = lines[1].strip()
With the id on line 1 of your text file and the password on line 2.
CodePudding user response:
You can use environment variables to decouple credentials and other sensitive content from your Python scripts.
import os
# Get environment variables
login_id = os.getenv('MY_LOGIN_ID')
password = os.environ.get('MY_PASSWORD')
You can configure this on OS level using
export MY_LOGIN_ID="my login"
export MY_PASSWORD="my password"