Python dict.get() raises KeyError

后端 未结 2 730
深忆病人
深忆病人 2021-01-13 12:11

I am getting lost here, Python 2.7, I have a dictionary mt, and I use the get() method, which by documentation says:

g

2条回答
  •  温柔的废话
    2021-01-13 12:36

    So I nailed the problem down. Before this code was put in place there was this one

    File "/home/ubuntu/subscription-workers/commands/dr/rebilling.py", line 48, in rebill
        if mt['is_rebill'] == 1:
    KeyError: 'is_rebill'
    

    The problem was that there were .pyc files from the older version, but the stack trace was loading the actual code. After running

    find . -name "*.pyc" -exec rm -rf {} \;
    

    and reloading the app everything was fine and without problems.

提交回复
热议问题