Python‎ > ‎integer‎ > ‎

int.to_bytes()

http://www.adilwaseem.com/


Introduction
Return an array of bytes representing an integer.

Syntax
int.to_bytes(length, byteorder, *, signed=False) -> bytes

Parameters
  • Integer
  • position
  • big or little
Examples
The method returns as:
 >>> (1112).to_bytes(4, byteorder='little')b'X\x04\x00\x00'
>>> (2221).to_bytes(10, byteorder='big')
b'\x00\x00\x00\x00\x00\x00\x00\x00\x08\xad'
>>> 

Comments