def op(gen, d):
if isinstance(d, int):
if d == 0:
return opcodes.OP_0
if d == -1 or 1 <= d <= 16:
return d + opcodes.OP_1 - 1
# Hmm, maybe time to switch to Python 3 with int.from_bytes?
h = "00%x" % (d if d >= 0 else -1-d)
if len(h) % 2:
h = h[1:]
elif h[2] < '8':
h = h[2:]
if d < 0:
import string
h = h.translate(string.maketrans('0123456789abcdef', 'fedcba9876543210'))
return h.decode('hex')
raise ValueError(n)
评论列表
文章目录