def serialize_output(output):
    if not ('value' in output and 'script_hex' in output):
        raise Exception('Invalid output')

    return ''.join([
        hexlify(struct.pack('<Q', output['value'])), # pack into 8 bites
        hexlify(variable_length_int(len(output['script_hex'])/2)),
        output['script_hex']
    ])
Serializes a transaction output.
dataset/ETHPy150Open blockstack/pybitcoin/pybitcoin/transactions/serialize.py/serialize_output