擅长:python、mysql、java
<p><a href="https://docs.python.org/3/library/stdtypes.html#int.to_bytes" rel="nofollow noreferrer">^{<cd1>}</a>仅适用于整数afaik。</p>
<p>您可以使用<a href="https://docs.python.org/3/library/stdtypes.html#bytearray.fromhex" rel="nofollow noreferrer">^{<cd2>}</a>:</p>
<pre><code>>>> ba = bytearray.fromhex("AA55CC3301AA55CC330F234567")
>>> ba.reverse()
</code></pre>
<p>要使用<a href="https://docs.python.org/3/library/functions.html#format" rel="nofollow noreferrer">^{<cd3>}</a>将其转换回字符串,请执行以下操作:</p>
<pre><code>>>> s = ''.join(format(x, '02x') for x in ba)
>>> print(s.upper())
6745230F33CC55AA0133CC55AA
</code></pre>