Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 如何在Python 3.2中剥离消息的开头和结尾_String_Python 3.x_Serial Port - Fatal编程技术网

String 如何在Python 3.2中剥离消息的开头和结尾

String 如何在Python 3.2中剥离消息的开头和结尾,string,python-3.x,serial-port,String,Python 3.x,Serial Port,我正在向python 3.2发送一条消息 VT=10000 当3.2得到它时,它增加了: b'VT=10000' 我发出这个命令的马达不理解额外的东西。 如何摆脱b和'? 我试着使用 string.strip() 但是可能我用错了。出现了b和”,因为在某个点上,您将字节对象视为str: >>> incoming = b'vt10000' >>> command = '%s' % incoming >>> print(repr(command)

我正在向python 3.2发送一条消息

VT=10000

当3.2得到它时,它增加了:

b'VT=10000'

我发出这个命令的马达不理解额外的东西。 如何摆脱b和'?

我试着使用

string.strip()


但是可能我用错了。

出现了
b
,因为在某个点上,您将
字节
对象视为
str

>>> incoming = b'vt10000'
>>> command = '%s' % incoming
>>> print(repr(command))
"b'vt10000'"

您向Python“发送消息”是什么意思?“b”和引号字符只是打印某些内容的工件,它们只是表明您正在处理a。b出现在python传递给arduino和rs232屏蔽的消息中添加生成并发送消息的代码。如果我能看到它是如何创建的,我可能可以帮你解决它。发送b是非常奇怪的,因为只有在打印字节对象时才会显示b。