Are there any Python modules that convert strings to binary? (like this site)

I googled 'python ascii to binary' and I found binascii but I can't figure out how to use it, well I don't think it's what I'm looking for.

My plan is to write a script that takes a string as input and then converts it to binary. So say the string was 'Hi', it would be converted to '01001000 01101001'. I was also wondering if there are any modules that can perform Boolean operations on the binary, for example, NOT every second bit.

Would it make sense to write my own modules to do this or would something like that be too complicated for a beginner?

Recommended Answers

All 2 Replies

In python 2. 6, have a look at the output of

bin(ord(character))

also

>>> bin(reduce(lambda x, y: 256*x+y, (ord(c) for c in "Hello world"), 0))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.