Last active
March 5, 2019 17:30
-
-
Save kstseng/cc248d4efcdd514ad569c9fcd325e7f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
python sample code for loading credential | |
''' | |
import configparser | |
config = configparser.ConfigParser() | |
config.read('~/.config/credential') | |
## section_a | |
username_a = config.get('section_a', 'username') | |
password_a = config.get('section_a', 'password') | |
## section_b | |
username_b = config.get('section_b', 'username') | |
password_b = config.get('section_b', 'password') | |
print('username_a: {}'.format(username_a)) | |
print('password_a: {}'.format(password_a)) | |
print('username_b: {}'.format(username_b)) | |
print('password_b: {}'.format(password_b)) | |
## username_a: abc | |
## password_a: 123 | |
## username_b: def | |
## password_b: 456 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment