The Artima Developer Community
Sponsored Link

Python Buzz Forum
bin2hex.py

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Thomas Guest

Posts: 236
Nickname: tag
Registered: Nov, 2004

Thomas Guest likes dynamic languages.
bin2hex.py Posted: Feb 12, 2007 1:12 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Thomas Guest.
Original Post: bin2hex.py
Feed Title: Word Aligned: Category Python
Feed URL: http://feeds.feedburner.com/WordAlignedCategoryPython
Feed Description: Dynamic languages in general. Python in particular. The adventures of a space sensitive programmer.
Latest Python Buzz Posts
Latest Python Buzz Posts by Thomas Guest
Latest Posts From Word Aligned: Category Python

Advertisement
bin2hex.py
#!/usr/bin/env python

# Reads binary data from stdin and converts it into
# comma separated hex numbers (suitable e.g. for
# inclusion in an array initialiser) written to stdout.

import sys, textwrap
print "\n".join(textwrap.wrap(
    ", ".join("0x%02x" % ord(b) for b in sys.stdin.read())))

Read: bin2hex.py

Topic: simplejson 1.5 Previous Topic   Next Topic Topic: Pycon hits 500

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use