python - 在 python 中通过套接字发送文件(内存错误)
问题描述
所以我有学校项目,我正在尝试读取文件,然后将其发送到服务器。该代码运行良好,但每当我尝试读取一个大文件时,我都会收到“内存错误”。该错误可能是由于文件的大小而发生的,但我该怎么做才能解决这个问题?
msg = self.encryptor.encrypt(b'#gf ' + open(' '.join(cmd.split(' ')[1:]), 'rb').read())
内存错误
def getFile(self, cmd):
msg = self.encryptor.encrypt(b'#gf ' + open(' '.join(cmd.split(' ')[1:]), 'rb').read())
self.client.send(self.encryptor.encrypt(str(len(msg)).encode()))
self.client.send(msg)
我在第 2 行有错误。
解决方案
推荐阅读
- javascript - PHP 执行函数作为函数的参数
- html - react js项目中显示未定义的黑色
- git - 克隆使用 --mirror 创建的本地 git 存储库
- javascript - 数组中的 GSAP 3+ 补间值
- security - Azure Devops 删除域用户组权限
- c++ - 具有类型名称的矩阵之和
- python - Search in Dynamodb db
- matlab - matlab2012a 在清除 mex 后卡在“忙碌”状态
- c# - 如何在 Visual Studio 中从 nuget 包中排除依赖项
- wordpress - WooCommerce 付款电子邮件已完成但未收到管理员