All pastes #607944 Raw Edit

zoredache

public python v1 · immutable
·published 2007-07-08 00:08 UTC
rendered paste body
#!/usr/bin/python# Pipe file into this to display the binary values of each byte in the file# Author: zoredacheimport syswhile 1:  # grab a line from input  line = sys.stdin.readline()  if not line:    break  # loop across all the characters in a line  for i in range(len(line)):    # int value of character    charval=ord(line[i])    # string displaying the binary value    binval=''.join([str((charval >> y) & 1) for y in range(7,-1,-1)])    # print the results    print "%s = %s" % ( binval, str(charval))