title: How to output integer arrays to file in python?
body: <p>I have 3000000 ints' long array which I want to output to a file. How can I do that?
  Also, is this</p>
  
  <pre><code>for i in range(1000):
      for k in range(1000):
          (r, g, b) = rgb_im.getpixel((i, k))
          rr.append(r)
          gg.append(g)
          bb.append(b)
  d.extend(rr)
  d.extend(gg)
  d.extend(bb)
  </code></pre>
  
  <p>a good practice to join array together?</p>
  
  <p>All of the arrays are declared like this <code>d = array('B')</code></p>
  
  <p>EDIT:
  Managed to output all int`s delimited by ' ' with this</p>
  
  <pre><code>from PIL import Image
  import array
  
  side = 500
  
  for j in range(1000):
      im = Image.open(r'C:\Users\Ivars\Desktop\RS\Shape\%02d.jpg' % (j))
      rgb_im = im.convert('RGB')
      d = array.array('B')
      rr = array.array('B')
      gg = array.array('B')
      bb = array.array('B')
      f = open(r'C:\Users\Ivars\Desktop\RS\ShapeData\%02d.txt' % (j), 'w')
      for i in range(side):
          for k in range(side):
              (r, g, b) = rgb_im.getpixel((i, k))
              rr.append(r)
              gg.append(g)
              bb.append(b)
      d.extend(rr)
      d.extend(gg)
      d.extend(bb)
      o = ' '.join(str(t) for t in d)
      print('#', j, ' - ', len(o))
      f.write(o)
      f.close()
  </code></pre>