Advertisement
Guest User

Untitled

a guest
Nov 27th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. filename = os.path.join(os.path.dirname(__file__), 'config.txt')
  2. with open(filename, 'a+') as f:
  3. config = configparser.ConfigParser(defaults={'username': '', 'password': ''})
  4. f.seek(0)
  5. config.read_file(f)
  6. username = config.get(configparser.DEFAULTSECT, 'username')
  7. password = config.get(configparser.DEFAULTSECT, 'password')
  8. username = input('username (leave blank to use \'{}\'): '.format(username)) or username
  9. password = input('password : ') or password
  10. print(username)
  11. config.set(configparser.DEFAULTSECT, 'username', username)
  12. config.set(configparser.DEFAULTSECT, 'password', password)
  13. config.write(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement