2016-01-21 48 views
1

我得到這個錯誤:Python的插座,屬性錯誤海峽有沒有屬性加密

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')) 
+0

而client_sender函數的定義在這裏並不重要,它稍後將它的參數傳遞給發送它的套接字 –

回答

1

你可能想要去與

buffer.encode('utf8') 

爲了使該字符串是一個字節對象並將其傳遞給套接字連接。

相關問題