Converting a string of 1's and 0's to a byte array
<p>I have a string with a length that is a multiple of 8 that contains only 0's and 1's.  I want to convert the string into a byte array suitable for writing to a file.  For instance, if I have the string "0010011010011101", I want to get the byte array [0x26, 0x9d], which, when written to file, will give 0x269d as the binary (raw) contents.</p>

<p>How can I do this in Python?</p>
