Skip to content

Instantly share code, notes, and snippets.

@kstseng
Last active March 5, 2019 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kstseng/cc248d4efcdd514ad569c9fcd325e7f0 to your computer and use it in GitHub Desktop.
Save kstseng/cc248d4efcdd514ad569c9fcd325e7f0 to your computer and use it in GitHub Desktop.
'''
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