转换<;类别';字节'&燃气轮机;到字符串';0';和';1';python
如何转换类“字节”的对象 b'\xd2\x9f\r' 到“0”和“1”的字符串 0010110110000010 使用下面的代码转换<;类别';字节'&燃气轮机;到字符串';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
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