Home > other >  Python dictionary repeat key, to achieve print out two key, how to write
Python dictionary repeat key, to achieve print out two key, how to write

Time:04-27

I={
Func '[]' : '1',
Func '[]' : '2',
}
Print (I)
The actual output {' func [] ':' 2 '}

Want to output {' func [] ':' 1 ', 'func []' : '2'}
Need to how to set

CodePudding user response:

Python does not allow twice in the same key, and created if the same key assigned twice, after a value will be remembered

CodePudding user response:

I={
Func '1', '[]',
Func '2' : '[]',
}
For j in I:
Print (' I want to be a key: + I [j])
Print (' I'm going to the duty + j)
  • Related