Convert a binary number in a list back to its decimal form in python?
How would I convert a binary string to a decimal number? I am taking the binary out of a list of values, and need to then convert it to decimal format.
ex. x=["0b000101"]
needs开发者_StackOverflow to become x= [5]
Is this Possible?
In [66]: x
Out[66]: ['0b000101']
In [67]: [int(elt,base=2) for elt in x]
Out[67]: [5]
精彩评论