Having opened a binary pdf file, I try to save it into a new file, open for writing binary. but instead of characters there are records like \ x00 \ x14QE \ x00 \ xa2 \ x8a. How to fix it.

f = open('1.pdf', 'rb') str_b = f.read() f.close() f2 = open('2.pdf', 'wb') f2.write(str_b) f2.close() 
  • Similarly, f2 = open ('2.pdf', wb) , not f2 = open ('2.pdf', 'wb') ? Yes, and how to open 2.pdf to see records like \ x00 \ x14QE \ x00 \ xa2 \ x8a? - gil9red
  • Opened in Kate. With quotes, that's right, I rewrote it. - Vladimir
  • The code you give seems to be unable to do so. Are you sure this is a minimal reproducible example ? Did you run this particular code and still get this problem? - andreymal
  • The code is minimally adapted to the problem. I read pdf from the http stream, and the question is what you need \ x8a \ x27 bytes byte and write, not symbolism - Vladimir
  • No, let's do it again: did you run THIS code and get a problem with it? About http forget - in the code shown by you there is no http. - andreymal

0