Python: Converting a Text File to a Binary File
问题 We can convert any digital file into binary file. I have a text file of 1MB, I want to convert it to a binary string and see the output as a binary number and the vice versa, in other words, if I have binary number, I want to convert it to a text file. How could I do that in Python? is there a standard way to do this? Now in this forum there are some posts (1,2,3, 4 ) on this but none of them answer properly to my question. 回答1: See https://docs.python.org/3/library/codecs.html#standard