Python 字符串与二进制串的相互转换

def encode(s):
    return ' '.join([bin(ord(c)).replace('0b', '') for c in s])
 
def decode(s):
    return ''.join([chr(i) for i in [int(b, 2) for b in s.split(' ')]])

  

猜你喜欢

转载自www.cnblogs.com/clear93/p/11097379.html
今日推荐