As shown in the following script, I want to update values of a nested dictionary “d2“:
如以下脚本所示,我希望更新嵌套字典“D2”的值:
d1 = dict( STRING, ANY )
d2 = dict( STRING, ANY )
d2[`d2_K] = 1
d1[`d1_K] = d2
d1[`d1_K][`d2_K] = 3
But when I executed the last line of code, I encountered an error: Please use '==' rather than '=' as equal operator in non-sql expression
.
但是当我执行最后一行代码时,我遇到了一个错误:请在非SQL表达式中使用‘==’而不是‘=’作为等于运算符。
I tried an alternative approach:
我尝试了另一种方法:
d1 = dict( STRING, ANY )
d2 = dict( STRING, ANY )
d2[`d2_K] = 1
d1[`d1_K] = d2
d2[`d2_K] = 3
But another error was reported: Object without ownership could not be modified
.
但报告了另一个错误:无法修改没有所有权的对象。
Could someone explain the causes behind these errors?
谁能解释一下这些错误背后的原因?
更多回答
优秀答案推荐
- The first error occurs because assignment operation is not supported
in d1[
d1_K][d2_K] = 3
.
- The second error occurs because “d2[`d2_K]” is read-only and cannot
be modified.
更多回答
我是一名优秀的程序员,十分优秀!