Created
December 5, 2011 17:50
-
-
Save nickjacob/1434548 to your computer and use it in GitHub Desktop.
simple python script to convert string to binary ASCII with each character on a new line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def toBin(s): | |
# removes space characters, puts each ascii code on a new line | |
print "\n".join(filter(lambda x:x!="100000",[bin(ord(c))[2:] for c in s])) | |
if __name__ == "__main__": | |
s = input("enter a string: \n") | |
toBin(s) | |
# or: | |
if __name__ == "__main__": | |
print "\n".join(filter(lambda x:x!="100000",[bin(ord(c))[2:] for c in input("enter a string:\n")])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment