Discuss / Python / 编码错误

编码错误

Topic source

________却

#1 Created at ... [Delete] [Delete and Lock User]

client发出的是utf-8编码的bytes 到了server以后用%s格式化的时候要先decode 然后加上hello以后再encode成utf-8,即

s.sendto(('Hello, %s!' % data.decode('utf-8')).encode('utf-8'), addr)

  • 1

Reply