发布网友 发布时间:2022-04-25 15:53
共1个回答
热心网友 时间:2022-04-07 12:36
def btos(b):
->ans = []
->for bb in range(0,len(b)-1,8):
->->i = int(b[bb:bb+8],2)
->->ans.append(i)
->return bytes(ans).decode('utf8')
def stob(s):
->b = s.encode('utf8')
->ans = ''
->for bb in b:
->->anss = int(bin(bb)[2:])
->->ans += '{:08d}'.format(anss)
->return ans