开发者

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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜