类内的调用函数

2024-05-16 04:03:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我曾尝试将函数W_Kpower(scpi_comm)集成到一个类中,但遇到一个错误:

  keithley = rm.open_resource(instControl(inst_list))
NameError: global name 'self' is not defined

你能帮我把这个函数集成到一个类中吗。我需要在以后的其他课程中使用。我是初学者,所以我不了解我的代码的所有细节。在

^{pr2}$

Tags: 函数rmname错误scpiopenglobalresource
1条回答
网友
1楼 · 发布于 2024-05-16 04:03:21

此处的方法定义中缺少self

def W_KPower(scpi_comm):  # this should be def W_KPower(self, scpi_comm)
    return self.keithleyPower.write(":syst:loc")

我想在这里,你需要self.

^{pr2}$

相关问题 更多 >