S
S
Sorin Ciobanu2018-03-03 09:58:23
Python
Sorin Ciobanu, 2018-03-03 09:58:23

How to assign a value to a specific dictionary key?

Good day.
Faced a problem when changing the value in the dictionary.
There is a dictionary with this structure

{
  "1": {
    "nonce": 1510009763,
    "A": {
    },
    "B": {
    },
    "C": {
    },
    "D": {
    }
  },
  "5": {
    "nonce": 1510009763,
    "A": {
    },
    "B": {
    },
    "C": {
    },
    "D": {
    }
  },
  "15": {
    "nonce": 1510009763,
    "A": {
    },
    "B": {
    },
    "C": {
    },
    "D": {
    }
  },
}

the value 1,5,15 is the time in minutes
if int(self.exportData[keyFirst]['nonce']) + (int(keyFirst) * 60) <= int(time.time()):
                    self.exportData[keyFirst]['nonce'] = int(time.time())

When this line is executed, for reasons unknown to me, the updated time is assigned to all keys [1][nonce] / [5][nonce].
Please explain why this is happening
python 3.5

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question