我想復制串列中的字典并將其附加到串列中。
foci=[
{
"label": "Monday 1:00 pm",
"value": {
"input": {
"text": "Monday 1:00 pm"
}
}
}
]
uj5u.com熱心網友回復:
您需要deepcopy嵌套的 dict 并將其附加到串列中:
from copy import deepcopy
foci = [
{
"label": "Monday 1:00 pm",
"value": {
"input": {
"text": "Monday 1:00 pm"
}
}
}
]
foci.append(deepcopy(foci[0]))
print(foci)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/365722.html
