When the keys in the dictionary are repeated - a difference between pycharm and python IDLE printing

Two occurrences of the same key are not allowed in python. If the same key is assigned twice during creation, the latter value will be remembered, as in the following example:

dict1 = { ' Name ' : ' Runoob ' , ' Age ' : 7, ' Name ' : ' Little Rookie ' }

print ("dict1['Name']: ", dict1['Name'])

If it is pycharm (community edition v3.4.4), pycharm will prompt: Dictionary contains duplicate keys 'Name' more...

Not actually printed:

 If python comes with IDLE, it will print the last value of the same key

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324382349&siteId=291194637