如何解决 Python 脚本中的 NameError 错误在 Linux CentOS 上

问题描述

我正在尝试在 Cent OS 8 上制作 Python 脚本,但我不断收到此“NameError”消息,我无法弄清楚可能是什么问题。在这里,您将看到我的脚本和错误消息的屏幕截图。

The error message

My script

预先感谢您的帮助。

解决方法

您必须提及文件“sshdlog”的完整路径,例如 with open("full path to sshdlog file") as f 或您的脚本和 sshdlog 在同一目录中。