I want to write 8 bit unsigned integers to file. In c++ we can do it using fprintf in which the format is:
%[flags][width][.precision][length]specifier
Is there any way I can do it using python? I tried finding the size of the file by asigning value of x =1 to print only 9 integer values, I didn't understand how the file size was 35 bytes.
f = open('myfile','w')
while x>0:
for i in range(0,9):
a[i] = random.randint(0,255)
f.write("%d" % a[i])
f.write(" ")
f.write('\n')
x = x-1
f.close()

1is one character/byte,10is two characters/bytes,100is 3 characters/bytes, and yourerandint()just happened to generate numbers that come to 24 chars/bytes (+ 10 spaces + newline)