ixxra

binary2human.py

May 19th, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. import sys
  2.  
  3. def char_from_binary(word):
  4.     x = 0
  5.  
  6.     for i in range(8):
  7.         c = int(word[i])
  8.        
  9.         if c != 0:
  10.             x += 2**(7 - i)
  11.  
  12.     return chr(x)
  13.  
  14. for word in sys.argv[1:]:
  15.     print (chr(int(word, 2)), end='')
  16.  
  17. print ('')
Advertisement
Add Comment
Please, Sign In to add comment