Python套接字,属性错误str没有属性加密

标签 python sockets python-3.x

我收到此错误:

AttributeError: 'str' object has no attribute 'encrypt'

运行这些代码行时。它们位于函数的定义内部(导入行除外)。顺便问一下,函数encrypt()来自哪个库?

 import socket
 import sys
 import getopt
 import threading
 import subprocess
     buffer="lol"
     client_sender(buffer.encrypt('utf-8'))

最佳答案

你可能想一起去

buffer.encode('utf8')

为了使字符串成为字节对象并将其传递给套接字连接。

关于Python套接字,属性错误str没有属性加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34930888/

相关文章:

python - Python 中的 *tuple 和 **dict 是什么意思?

Python:从 EXIF 中提取西里尔字符串

java - 如何在java中屏蔽字节来获取条件

C#套接字接收线程

python - 如何制作透明的pygame.draw.circle

python-3.x - 除非使用 sudo 运行,否则 Python 脚本不起作用

python - 如何将Python程序转换为可执行文件[Python 3.4.2]

python - 如何获得列中列表的最大值和最小值?

python - 如何以张量形式从 tensorflow 或 Keras 中的混淆矩阵获得准确性?

c - 非阻塞Socket连接总是成功?