Traceback (most recent call last): File "C:\Users\Mayn\pyProject\TBO_lib\tbobus.py", line 194, in <module> s1.sensor_s0_wirte(34) File "C:\Users\Mayn\pyProject\TBO_lib\tbobus.py", line 180, in sensor_s0_wirte self.modbus_s.wirte(slave, self.s_addr0, output_valu=[1,0,1,1]) File "C:\Users\Mayn\pyProject\TBO_lib\tbobus.py", line 106, in wirte self.master.execute(slave, cst.WRITE_MULTIPLE_REGISTERS, reg_start, output_valu) File "C:\Users\Mayn\AppData\Local\Programs\Python\Python311\Lib\site-packages\modbus_tk\utils.py", line 39, in new raise excpt File "C:\Users\Mayn\AppData\Local\Programs\Python\Python311\Lib\site-packages\modbus_tk\utils.py", line 37, in new ret = fcn(*args, **kwargs) File "C:\Users\Mayn\AppData\Local\Programs\Python\Python311\Lib\site-packages\modbus_tk\modbus.py", line 222, in execute byte_count = 2 * len(output_value) TypeError: object of type 'int' has no len()
时间: 2023-07-21 18:01:29 浏览: 300
Mac下anaconda中Spyder打开报错Traceback(most recent call last)…问题
5星 · 资源好评率100%
这个错误是由于在执行`self.master.execute`时,`output_valu`参数传入了一个整数值,而`len()`函数无法用于整数类型的对象。`len()`函数通常用于获取字符串、列表等可迭代对象的长度。要解决这个错误,您需要确保`output_valu`参数是一个可迭代对象,例如列表或元组。请检查您的代码,确保在调用`sensor_s0_wirte`方法时,`output_valu`参数的类型正确并且是一个可迭代对象。
阅读全文