Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.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
转换<;类别';字节'&燃气轮机;到字符串';0';和';1';python_Python_Python 3.x_Encoding_Decoding - Fatal编程技术网

转换<;类别';字节'&燃气轮机;到字符串';0';和';1';python

转换<;类别';字节'&燃气轮机;到字符串';0';和';1';python,python,python-3.x,encoding,decoding,Python,Python 3.x,Encoding,Decoding,如何转换类“字节”的对象 b'\xd2\x9f\r' 到“0”和“1”的字符串 0010110110000010 使用下面的代码 import sys bin(int.from_bytes(b'\xd2\x9f\r', byteorder=sys.byteorder)) 输出 0b11011001111111010010使用下面的代码 import sys bin(int.from_bytes(b'\xd2\x9f\r', byteorder=sys.byteorder)) 输出 0b110

如何转换类“字节”的对象

b'\xd2\x9f\r'

到“0”和“1”的字符串

0010110110000010

使用下面的代码

import sys
bin(int.from_bytes(b'\xd2\x9f\r', byteorder=sys.byteorder))
输出
0b11011001111111010010

使用下面的代码

import sys
bin(int.from_bytes(b'\xd2\x9f\r', byteorder=sys.byteorder))
输出
0b11011001111111010010

在ESP32上的Micropython中,结果是:

>>> bin(int.from_bytes(b'-\x05\x05\xff',byteorder=sys.byteorder))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function doesn't take keyword arguments

在ESP32上的Micropython中,结果是:

>>> bin(int.from_bytes(b'-\x05\x05\xff',byteorder=sys.byteorder))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function doesn't take keyword arguments