For reference—future Python possibilities:
Starting with Python 2.6 you can express binary literals using the prefix 0b or 0B:
>>> 0b101111 47
You can also use the new bin function to get the binary representation of a number:
>>> bin(173) '0b10101101'
Development version of the documentation: What’s New in Python 2.6
Related Posts:
- What does “while True” mean in Python?
- What is the difference between {} and [] in python?
- syntaxerror: “unexpected character after line continuation character in python” math
- Can someone explain __all__ in Python?
- How to exit a loop in Python?
- How can I do a line break (line continuation) in Python?
- What does the /= operator mean in Python?
- What do >> and << mean in Python?
- Is there a difference between `continue` and `pass` in a for loop in python?
- Converting binary to decimal integer output
- What does `<>` mean in Python?
- What does the “at” (@) symbol do in Python?
- What is :: (double colon) in Python when subscripting sequences?
- What’s the u prefix in a Python string?
- Error “‘type’ object has no attribute ‘__getitem__'” when iterating over list[“a”,”b”,”c”]
- Python def function: How do you specify the end of the function?
- No Multiline Lambda in Python: Why not?
- Converting integer to binary in python
- How do you round UP a number?
- How do you round UP a number?
- What does ** (double star/asterisk) and * (star/asterisk) do for parameters?
- Python integer incrementing with ++ [duplicate]
- Converting integer to string in Python
- What is the result of % in Python?
- What’s the meaning of “=>” (an arrow formed from equals & greater than) in JavaScript?
- Maximum and Minimum values for ints
- Maximum and Minimum values for ints
- IndentationError: unexpected indent error
- Putting a simple if-then-else statement on one line [duplicate]
- Safest way to convert float to integer in python?
- How do I parse a string to a float or int?
- How can I do a line break (line continuation)?
- How do you comment out code in PowerShell?
- How do I break a string in YAML over multiple lines?
- Round a floating-point number down to the nearest integer?
- What does ‘&’ do in a C++ declaration?
- syntaxerror: “unexpected character after line continuation character in python” math
- syntaxerror: “unexpected character after line continuation character in python” math
- `from … import` vs `import .` [duplicate]
- Tab space in Markdown
- syntax error when using command line in python
- In JavaScript is != same as !==
- What does ** (double star/asterisk) and * (star/asterisk) do for parameters?
- syntax error when using command line in python
- What Does This Mean in PHP -> or =>
- Comments in Markdown
- How do I pass multiple parameters into a function in PowerShell?
- Maximum and Minimum values for ints
- Comments in Markdown
- What is the difference between syntax and semantics in programming languages?
- Binary numbers in Python
- Python: SyntaxError: keyword can’t be an expression
- Reading a binary file with python
- Python: TypeError: cannot concatenate ‘str’ and ‘int’ objects
- What does the ‘b’ character do in front of a string literal?
- How can I convert a character to a integer in Python, and viceversa?
- What do << or >>> in java mean?
- Reading a binary file with python
- What does the ‘b’ character do in front of a string literal?
- How can I convert a character to a integer in Python, and viceversa?
- What is the Java ?: operator called and what does it do?
- Empty set literal?
- How to convert string to binary?
- Convert hex to binary
- Convert decimal to binary in python
- How do I convert a float number to a whole number in JavaScript?
- hat does “static” mean in C?
- How does Python manage int and long?
- Python int to binary string?
- Checking whether a variable is an integer or not
- How to normalize a 2-dimensional numpy array in python less verbose?
- Ternary operator (?:) in Bash
- SyntaxError invalid token
- How to convert string to binary?
- What is the difference between ‘/’ and ‘//’ when used for division?
- python “TypeError: ‘numpy.float64’ object cannot be interpreted as an integer”
- Is there a difference between x++ and ++x in java?
- Printing variables in Python 3.4
- What does the “@” symbol do in PowerShell?
- How to convert ‘binary string’ to normal string in Python3?
- Static Semantics meaning?
- What does the `and` keyword mean in OCaml?
- text highlight in markdown
- Display number with leading zeros
- Inline for loop
- Python conversion from binary string to hexadecimal
- What does ‘wb’ mean in this code, using Python?
- What does @@variable mean in Ruby?
- Convert floats to ints in Pandas?
- Python def marked as invalid syntax
- How do you format an unsigned long long int using printf?
- How to find length of digits in an integer?
- python ValueError: invalid literal for float()
- What are those pipe symbols for in Ruby?
- bash: syntax error near unexpected token `(‘ – Python
- Prolog “or” operator, query
- Convert int to ASCII and back in Python
- How to find which version of TensorFlow is installed in my system?
- Understanding the Python ‘with’ statement
- Replacing Pandas or Numpy Nan with a None to use with MysqlDB