我试图通过Python从PLC Micro Logics 1400(Allen Bradley(读取数据,并将其转储到MS SQL,然后"只能将str(而不是"字节"(连接到str">从PLC Micro Logics 1400读取数据时发生此错误。我将附加我目前正在使用的python程序。如果有人知道这个问题的解决方案,请帮助我。
https://drive.google.com/file/d/1C-g4M5YhtsvvTCaDnz3jLhYuRg64E-8f/view?usp=sharing
谢谢!
在bytes
对象上使用decode
方法将bytes
数据转换为str
。
例如,
hello = b"Hello"
print(type(hello))
>> <class 'bytes'>
hello.decode("utf-8")
print(type(hello))
>> <class 'str'>
然后可以将bytes
对象与str
连接起来。
*("utf-8"
是一种编码类型,您需要确定用于无错误解码字节对象的编码类型(