Conversion of an array of integers to string
If you are going to be playing with string representations of native types, you probably want to take a look at the struct standard library package.

With it, you can quickly process your r as follows:

&gt;&gt;&gt; import struct
&gt;&gt;&gt; ''.join(struct.pack('i', rr) for rr in r)
'012345678\x00\x00\x00\x00\x00\x00\x00'


And you can play with the ordering of the characters by explicitly describing the endianess of your input:

&gt;&gt;&gt; ''.join(struct.pack('&gt;i', rr) for rr in r)  # big endian
'32107654\x00\x00\x008\x00\x00\x00\x00'