title: How to store 256 as an integer in a file?
body: <p>I am learning LZW data compression, and i wanted to store numbers > 255 in a file. The numbers should not be stored as strings otherwise compression will not be effective. However, a binary file only stores numbers &lt;= 255. How can i store numbers greater than 255, such that when i read them back, i get original integer back ?</p>
  
  <pre><code>lst = [256]
  
  writefile = open("C:/Users/Dhruv/Desktop/write.bin", "wb")
  
  buffer = bytes(lst)
  
  print(buffer)
  
  writefile.write(buffer)
  writefile.close()
  readfile = open("C:/Users/Dhruv/Desktop/write.bin", "rb")
  bin = readfile.read(1)
  
  print(ord(bin))
  
  readfile.close()
  </code></pre>