如何将 ASCII 323534 转换为十进制 254

How can I convert ASCII 323534 into decimal 254

我有 ascii 数据 323534,十进制为 254。

我如何在 python 中写这个,所以我有输入 323534 和输出 int with 254

提前致谢。 这没有用

DistanceP1 = chr(32)
DistanceP2 = chr(35)
DistanceP3 = chr(34)
DistanceAll = [DistanceP1,DistanceP2,DistanceP3]
distance = int(''.join(DistanceAll))

数字323534实际上是254的十六进制表示。

您可以改为:

print(bytearray.fromhex("323534").decode())

输出

254