Use struck modules: struct two modules is the most important function pack () package, unpack () unpacked.
# Coding: UTF. 8-
Import struct
A = 18 is
bytes = struct.pack ( ' I ' , A)
Print ( " length after Pack S%: " % A, len (bytes)) length after # 18 pack: 4
Print (bytes) B # '\ X12 \ xOO \ xOO \ xOO'
S = struct.unpack ( ' I ' , bytes) [0]
Print (S) # 18 is