Am 24.02.2011 17:19, schrieb s...@uce.gov:
Is there a better way to convert int to bytes then going through strings:
x=5
str(x).encode()
Thanks.
bytes([8])
b'\x08'
seems more straight forward...
--
http://mail.python.org/mailman/listinfo/python-list
Am 26.02.2011 12:26, schrieb J. Gerlach:
Am 24.02.2011 17:19, schrieb s...@uce.gov:
Is there a better way to convert int to bytes then going through strings:
x=5
str(x).encode()
Thanks.
bytes([8])
b'\x08'
seems more straight forward...
... but it gives a different result. I
Is there a better way to convert int to bytes then going through strings:
x=5
str(x).encode()
Thanks.
--
Yves. http://www.SollerS.ca/
http://blog.zioup.org/
--
On 2/24/2011 11:19 AM, s...@uce.gov wrote:
Is there a better way to convert int to bytes then going through strings:
x=5
str(x).encode()
(This being Py3)
If 0 = x = 9, bytes((ord('0')+n,)) will work. Otherwise, no. You would
have to do the same thing str(int) does, which is to reverse the
On Feb 25, 4:39 am, Terry Reedy wrote:
Note: an as yet undocumented feature of bytes (at least in Py3) is that
bytes(count) == bytes()*count == b'\x00'*count.
Python 3.1.3 docs for bytes() say same constructor args as for
bytearray(); this says about the source parameter: If it is an
integer,
On 2/24/2011 9:25 PM, John Machin wrote:
On Feb 25, 4:39 am, Terry Reedy wrote:
Note: an as yet undocumented feature of bytes (at least in Py3) is that
bytes(count) == bytes()*count == b'\x00'*count.
Python 3.1.3 docs for bytes() say same constructor args as for
bytearray(); this says about