title: python replace string method in read file as binary
body: <p>I opened an image file in readbinary("rb") mode and stored the data in a variable. Now i want to replace some values in the binary with my values.. but its not working using usual replace method of string</p>
  
  <pre><code>f=open("a.jpg","rb")
  a=f.read()
  
  ''' first line is '\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00\xff\xe1\x00*Exif\x00\x00II*\x00\x08\x00\x00\x00\x0 '''
  
  a=a.replace("ff","z")
  print a
  
  #but there's no change in a
  </code></pre>
  
  <p>can anyone tell where iam going wrong.. i also tried</p>
  
  <pre><code>a=a.replace(b'ff',b'z')
  </code></pre>
  
  <p>but still the output was unchanged.</p>
  
  <p>can anyone tell what iam supposed to do to perform the replacement?</p>