Python3报错:AttributeError: 'dict' object has no attribute 'has_key'

Python3报错:AttributeError: 'dict' object has no attribute 'has_key'

出现这种错误是因为python版本兼容问题:has_key方法在Python2中方法,在Python3没有

如:

loc_dict.has_key(location)

改为:

if location in loc_dict
发布了496 篇原创文章 · 获赞 464 · 访问量 86万+

猜你喜欢

转载自blog.csdn.net/zhangvalue/article/details/103927713
今日推荐