Python-八进制转二进制
input_str = input('请输入待转八进制数:')
list_num = []
list_octal = []
lists = []
t = 0
def octal_binary():
"""用于八进制转二进制"""
for i in input_str:
list_num.append(i)
# print(list_num)
list_deal = [int(k) for k in list_num]
# print(list_deal)
list_num.clear()
for j in list_deal:
while True:
if j != 1:
n = str(j % 2)
list_octal.append(n)
j //= 2
elif j == 1:
list_octal.append('1')
list_octal.reverse()
if len(list_octal) % 3 == 0:
pass
elif len(list_octal) % 3 == 1:
list_octal.insert(0, '0')
list_octal.insert(1, '0')
elif len(list_octal) % 3 == 2:
list_octal.insert(0