sock.send(“ok”)
出现TypeError:a bytes-like object is required not ‘str’
采用如下方式处理即可
cmd=“ok”
sock.send(cmd.encode())
a bytes-like object is required not 'str'
最新推荐文章于 2023-12-14 09:26:26 发布
本文解决了一个常见的Python Socket编程错误:当尝试发送字符串而非字节类型数据时,出现TypeError。通过简单地将字符串转换为字节类型,问题得以解决。
6540

被折叠的 条评论
为什么被折叠?



