Using int() method, we can convert a binary string to integer value.
Example
int(binary_str, 2)
binary_string_to_integer.py
def get_int(binary_str):
return int(binary_str, 2)
print('"1010" -> ', get_int('1010'))
Output
"1010" -> 10
This blog is primarily focus on Java fundamentals and the libraries built on top of Java programming language. Most of the post are example oriented, hope you have fun in reading my blog....:)
Using int() method, we can convert a binary string to integer value.
Example
int(binary_str, 2)
binary_string_to_integer.py
def get_int(binary_str):
return int(binary_str, 2)
print('"1010" -> ', get_int('1010'))
Output
"1010" -> 10
No comments:
Post a Comment