📌  相关文章
📜  在 python 代码示例中将二进制转换为八进制

📅  最后修改于: 2022-03-11 14:46:46.456000             🧑  作者: Mango

代码示例2
==== Convert binary to octal in Python =====
binaryNum = '11001100'  # input a binary

decimalNum = int(binaryNum, 2)  # base 2 to base 10
print(decimalNum, type(decimalNum))  # 204 

octalNum = oct(decimalNum)[2:]  # base 10 to base 8
print(octalNum, type(octalNum))  # 314