import socket
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
connection.connect(("192.168.152.140", 4444))
connection.send("\n[ ] connection established.\n")
connection.close()
uj5u.com熱心網友回復:
嘗試這個
connection.send("\n[ ] connection established.\n".encode())
這應該作業
uj5u.com熱心網友回復:
您的 connection.send 引數需要是位元組,但您傳遞的是一個字串。您應該在發送之前對其進行編碼,例如 message.encode('utf-8')
message = "\n[ ] connection established.\n";
connection.send(message.encode('utf-8'));
uj5u.com熱心網友回復:
該socket.send函式需要位元組,而不是字串(docs)
您需要在發送之前將字串轉換為位元組:https : //www.askpython.com/python/string/python-string-bytes-conversion
它應該看起來像這樣:
connection.send("\n[ ] connection established.\n".encode("utf-8"))
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/313414.html
