그래서 사전에서 사전의 사전을 반복해야합니다. 기본적으로 나는 사전에이 같은 정보를 저장하고있다 : 예를 들어이 내가 지금까지 가지고있는, 그래서 함수에서 값을 반복 함
accounts = {}
def accountcreator():
newusername = raw_input()
newpassword = raw_input()
UUID = 0
UUID += 1
accounts[newusername] = {newpassword:UUID}
그런 다음 다른 함수에 나는이 모든 값을 통해 루프합니다. 이렇게하면 모든 새 사용자 이름이 올바르게 반복됩니다.
def accounts():
for usernames in accounts:
#I do not know what to do from here on out
#I want it to loop through all of the newpasswords and UUID
#And the UUIDs would be saved to a new variable
모든 값을 반복하는 간단한 방법을 알려주십시오. 감사합니다!
def accountcreator():
newusername = raw_input() #For raw input I put in cool-account-name
newpassword = raw_input() #For raw input I put in this-is-a-password
UUID = 0
UUID += 1
accounts[newusername] = {newpassword:UUID} #So basically what is being saved is accounts[cool-account-name] = {this-is-a-password:1}
그래서 그런 일이 후 나는이 계정 기능을 발생하려면 :
편집 그래서 기본적으로 이것은 예입니다. 각각의 개별 항목을 인쇄하기를 원하므로 기본적으로 사용자 이름, 암호 및 UUID를 각각 인쇄합니다. 위의 정보와 함께 제공되므로 사용자 이름 : cool-account-name, 암호 : this-is-a-password 및 UUID : 1을 출력합니다.
[이 질문에 대한 답변보기 (http://stackoverflow.com/questions/3294889/iterating-over-dictionary-for-loops-in-python)을 참조하십시오. dict를 반복하는 것과 비슷한 문제 – fluidmotion