title: Save pixel data in txt format in PIL
body: <p>My program is to extract the pixel from an image and to save the pixel data in the text file for analysis. My picture is a binary image that gives only 255 and 0 's</p>
  
  <p><strong>Here is the program:</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>from PIL import Image
  
  im = Image.open("thresh.jpg")
  pixel = im.load()
  row, column = im.size
  for y in range(column)
      for x in range(row)
          pixel = pix[x, y]
  
  </code></pre>
  
  <p><strong>Question:</strong></p>
  
  <p>I want to save the <code>pixel</code> data in a text file. Suggest me some techniques to save the data.</p>