I'm trying to turn a red smiley(PPM) into a green smiley(PPM) by modifying the source code with python (I use PyCharm CE). When I print the source file, I have this :
b'P6\n100 100\n255\n\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...
The goal is to modify some triplets (\xff\xff\xff) to change pixels color. So I keep the header(P6\n100 100\n255\n) aside and I create an array to modify just:(\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...)
After modification, (I turn the red pixels into green pixels) I add a new code:
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, ...
How to turn this array into the same format(Ascii) than I had at the beginning; which was (\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff...)?