我已经在强制类型转换函数中定义了强制类型转换,但是它仍然显示NameError。我是python的新手,有人可以帮助我吗?非常感谢:)
class Sxxx:
~
~
def casts(self):
self.casts = casts
if self.casts == self.cast_limit:
print("xxxxxx")
pass
skkk=Sxxx()
skkk.casts
Traceback (most recent call last):
File "spell.py", line 41, in <module>
summon.casts()
File "spell.py", line 15, in casts
self.casts = casts
NameError: name 'casts' is not defined
答案 0 :(得分:-1)
问题在于serialPort.DataReceived +=SerialPortDataReceived;
private void SerialPortDataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine(serialPort.ReadLine());
}
是一个函数,因此必须用方括号调用casts
。