只需要用上python的bytes和str两种类型转换的函数encode()、decode()即可! str通过encode()方法可以编码为指定的bytes; 反过来,如果我们从网络或磁盘上读取了字节流,那么读到的数据就是bytes。要把bytes变为str,就需要用decode()方法; data = tcpclient.recv(1024) print( data.decode())