繁体   English   中英

如何在这里使用isinstance()而不是比较类型?

[英]How can I use isinstance() here instead of comparing types?

我正在尝试比较这两个变量,而pylint给我一个错误。

我不比较类型不怎么做。

for key in first_dict.keys():
    if type(first_dict[key]) != type(second_dict[key]):
        new_dict[key] = (first_dict[key], second_dict[key])

错误看起来像这样:

C: 13,11 Using type()instead of isinstance() for a typecheck. (unidiomatic-typecheck)
if not isinstance(first_dict[key], type(second_dict[key]))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM