Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- filename = os.path.join(os.path.dirname(__file__), 'config.txt')
- with open(filename, 'a+') as f:
- config = configparser.ConfigParser(defaults={'username': '', 'password': ''})
- f.seek(0)
- config.read_file(f)
- username = config.get(configparser.DEFAULTSECT, 'username')
- password = config.get(configparser.DEFAULTSECT, 'password')
- username = input('username (leave blank to use \'{}\'): '.format(username)) or username
- password = input('password : ') or password
- print(username)
- config.set(configparser.DEFAULTSECT, 'username', username)
- config.set(configparser.DEFAULTSECT, 'password', password)
- config.write(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement