#!/usr/bin/env python import sys while True: mask = 1 value = 0 for i in range(8): input = sys.stdin.read(1) if input == "": # EOF sys.stdout.flush() sys.exit(0) if ord(input) > 48: value = value | mask mask = mask << 1 sys.stdout.write(chr(value)) sys.stdout.flush()