将鼠标移至灰色代码上,出现Unused import statement,表示import声明不可用
点击灰色代码,代码的左上角会出现一个黄色的小灯泡
鼠标移至小灯泡上面,单机灯泡旁边的下三角
选择第一个optimize imports,点击旁边的倒三角,一定要选择最后一个suppress for statement
!里插入图片描述](https://img-blog.csdnimg.cn/20201208094120531.png)
可以看到问题已经被解决掉
原因是代码中加入了noinspection PyUnresolvedReferences的注释,导致无法使用
它专门针对“This inspection detects names that should resolve but don’t. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.”提示的情况。其作用是:让PyCharm 在代码检查时人为跳过某些特定部分的代码检查。