我遇到标题中提到的错误问题。
第一个原始代码如下:"¶" (ASCII 182)
rm = visa.ResourceManager()
cc = rm.open_resource("TCPIP::10.38.94.157::2049::SOCKET")
sendstr = '11004¶1¶1\n'
cc.write(sendstr)
Temp = cc.query()
print(Temp)
错误是:
UnicodeEncodeError: 'ascii' codec can't encode character '\xb6' in position 5: ordinal not in range(128)
然后我尝试添加encode('utf-8')
sendstr = '11004¶1¶1\n'.encode('utf-8')
cc.write(sendstr)
Temp = cc.query()
print(Temp)
新错误是
TypeError: endswith first arg must be bytes or a tuple of bytes, not str
我不知道怎么了。任何建议表示赞赏! 预先感谢!