a、将字符串转换成utf-8编码的字节,并输出,然后将该字节在转换成utf-8编码字符串,在输出

  b、将字符串转换后才能gbk编码的字节,并输出,然后将该字节在转换成gbk编码字符串,在输出


def main():
    n = "老男孩"
    nBytes_utf = n.encode('utf-8')
    nStr_utf = nBytes_utf.decode('utf-8')
    print(nBytes_utf)
    print(nStr_utf)
    nBytes_gbk = n.encode('gbk')
    nStr_gbk = nBytes_gbk.decode('gbk')
    print(nBytes_gbk)
    print(nStr_gbk)
if __name__ == '__main__':
    main()