Skip to content

Instantly share code, notes, and snippets.

@aeppert
Created December 19, 2016 18:20
Show Gist options
  • Select an option

  • Save aeppert/e0f2afbb3ed3af7db23b7f11ab795b8d to your computer and use it in GitHub Desktop.

Select an option

Save aeppert/e0f2afbb3ed3af7db23b7f11ab795b8d to your computer and use it in GitHub Desktop.
Covert a string as a command line argument to binary
#!/usr/bin/python
import sys
def to_bin(st):
return ' '.join(format(ord(x), 'b') for x in st)
def main(argv):
for x in argv[1:]:
print to_bin(x)
if __name__ == "__main__":
main(sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment