我正在尝试将新词典附加到词典的键上,但是失败并显示error like this image
我的代码:
Sep 12 23:35:19 ubuntu-s-18-04-uvgproject bash[4966]: your mercy for graceful operations on workers is 60 seconds
Sep 12 23:35:19 ubuntu-s-18-04-uvgproject bash[4966]: mapped 72920 bytes (71 KB) for 1 cores
Sep 12 23:35:19 ubuntu-s-18-04-uvgproject bash[4966]: *** Operational MODE: single process ***
Sep 12 23:35:19 ubuntu-s-18-04-uvgproject bash[4966]: failed to open python file api.py
Sep 12 23:35:19 ubuntu-s-18-04-uvgproject bash[4966]: unable to load app 0 (mountpoint='') (callable not found or import error)
Sep 12 23:35:19 ubuntu-s-18-04-uvgproject bash[4966]: *** no app loaded. going in full dynamic mode ***
Sep 12 23:35:19 ubuntu-s-18-04-uvgproject bash[4966]: uWSGI running as root, you can use --uid/--gid/--chroot options
Sep 12 23:35:19 ubuntu-s-18-04-uvgproject bash[4966]: *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Sep 12 23:35:19 ubuntu-s-18-04-uvgproject bash[4966]: *** uWSGI is running in multiple interpreter mode ***
Sep 12 23:35:19 ubuntu-s-18-04-uvgproject bash[4966]: spawned uWSGI worker 1 (and the only) (pid: 4966, cores: 1)
答案 0 :(得分:2)
您的词典包含其他词典。
只需设置内部字典的键:
dict['a'][3] ='3'
print(dict)
输出
{'a': {1: '1', 3: '3'}, 'b': {2: '2'}}
请注意,请勿使用dict
作为变量名。这是Python中的一种类型。
答案 1 :(得分:0)
字典没有添加方法。您可以简单地添加一个键值对D[key]=value
(如果存在{{1}),如果现在添加新的键值对,key
将被替换。
解决方案如下:
value