I have a script running for network devices configurations. there are different username and password combinations to login, so I have file of username and password, reading into dictionary.
I put the most used username and password combination in 1. line and I am expecting script to try this line first but it won't work. python seems to create dictionary like selecting lines randomly. and that costs me extra time to connect devices because sometimes it takes up to 4 tries to find correct username while the correct one is first line :)
What I mean:
file
username1:password1
username2:password2
username3:password3
What I expect to see: {username1:password1, username2:password2, username3:password3}
What happens: {username3:password3, username1:password1, username2:password2}
The part creating dictionary
with open('userandpass.txt', 'r') as f:
for line in f:
user, pwd = line.strip().split(':')
credentials[user] = pwd
Thank you guys! Used ordered dictionary, sorry for posting duplicate question.