Created
January 3, 2015 17:10
-
-
Save freundTech/af6cb76c2243152b5c68 to your computer and use it in GitHub Desktop.
ascii2bin python script
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
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