Skip to content

Instantly share code, notes, and snippets.

@nickjacob
Created December 5, 2011 17:50
Show Gist options
  • Save nickjacob/1434548 to your computer and use it in GitHub Desktop.
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
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