python-3.x - Python,TypeError:没有编码的字符串参数
问题描述
我需要一些帮助。由于某种原因,它一直显示 typeError:string 参数而没有编码,
sent_message = network_connect_join.send(bytes(sending_message)).encode('utf-8')
它的代码片段,下一行只是打印出正常的消息
解决方案
bytes()
处理字符串时需要两个参数:要转换为字节的字符串和要使用的编码。改为使用bytes(sending_message, 'utf-8')
。
推荐阅读
- list - Ocaml 中的 For 循环在脚本末尾引发语法错误
- python - 避免同时读取 dask 数组的多个文件
- function - 让绑定如何工作
- angular - 核心模块之外的 Angular 6 中的共享服务
- r - 用于在 RMarkdown 中使用 knitr 和 kableExtra 包创建多个表的 For 循环
- compilation - 在 Visual Studio 2017 上安装 C++“X64 编译器和工具”
- php - Laravel HTMLPurifier 过滤 base64 编码图像
- express - 添加猫鼬模式模型来表达导致错误500
- .net - 样式资源取决于字符串变量
- php - 使用 SQLite 在 laravel 中的身份验证问题