Skip to content

Instantly share code, notes, and snippets.

@freundTech
Created January 3, 2015 17:10
Show Gist options
  • Save freundTech/af6cb76c2243152b5c68 to your computer and use it in GitHub Desktop.
Save freundTech/af6cb76c2243152b5c68 to your computer and use it in GitHub Desktop.
ascii2bin python script
import sys
if len(sys.argv) == 1:
text = raw_input("Please enter a text: ")
else:
text = ""
for i, arg in enumerate(sys.argv[1:]):
text += arg
if i < len(sys.argv)-2:
text += " "
str_ = ""
for c in text:
code = ord(c)
str_ += "{0:08b}".format(code)
str_ += " "
print(str_)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment