Python: How can I print bytes?

Question:

I’m using Python 2.7.

I want to print a binary in decimal, but I’m receiving an error, which I do not understand.

Eg. I am trying:

print 0b111

I am expecting 7. But it returns:

Unescaped left brace in regex is deprecated, passed through in regex; marked by <– HERE in m/%{ <– HERE (.*?)}/ at /usr/bin/print line 528.
Error: no “print” mailcap rules found for type “text/x-python”

Can you help? Just a beginner with Python!

Asked By: francoiskroll

||

Answers:

… at /usr/bin/print …

Sounds like you’re invoking the script incorrectly. Either use a shebang that points to a Python executable or explicitly pass it to the executable.

python somescript.py
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.