最近开始学习Python,安装上最新的Python3.6.5  在使用django的时候 出现如下错误

‘dict’ object has no attribute 'has_key'

保留犯罪现场:

'dict' object has no attribute 'has_key' 解决办法

犯罪现场2:

'dict' object has no attribute 'has_key' 解决办法

查阅资料发现,Python3以后删除了has_key()方法

解决办法:

修改代码

[python] view plain copy
  1. if dict.has_key(key1):  
改为
[python] view plain copy
  1. if key1 in adict: 

最终修改如下:

'dict' object has no attribute 'has_key' 解决办法

至此解决

相关文章:

  • 2022-12-23
  • 2022-01-11
  • 2022-12-23
  • 2021-08-19
  • 2021-09-29
  • 2021-04-14
  • 2022-12-23
猜你喜欢
  • 2021-10-23
  • 2022-12-23
  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案