要么马特(Matt)在评论中说(bin(63)[2:].zfill(6)
),要么使用
Either what Matt said in the comment (bin(63)[2:].zfill(6)
), or use format strings in Python 2.6+:
'{0:06b}'.format(63)
您可以省略Python 2.7+中的第一个零,因为您可以隐式地对组进行编号.
You can omit the first zero in Python 2.7+ as you can implicitly number groups.