1.首先打开 pycharm
2.点击左上角的File按钮
![](https://img2020.cnblogs.com/blog/13318/202102/13318-20210202221648454-902197680.png)
3.在弹出的菜单栏中,找到 Invalidate Caches/ Restart ...按钮,翻译成中文就是清除缓存
![](https://img2020.cnblogs.com/blog/13318/202102/13318-20210202221658641-1486249085.png)
4.点击Invalidate这个按钮
![](https://img2020.cnblogs.com/blog/13318/202102/13318-20210202221819447-116506532.png)
for key in list(globals().keys()): if (not key.startswith("__")) and (key != "key"): globals().pop(key) print(key) del key 链接:https://www.zhihu.com/question/407406116/answer/1343971607