我通過定義執行程序函數繼承了類客戶機節點中類NetworkUtility中定義的函數。 你能告訴我,爲什麼它顯示以上錯誤。我對此毫無頭緒。TypeError:executor()不帶參數(給出1)
#!/usr/bin/python
import socket
from NetworkUtility import NetworkUtility
#import json
HOST = '' # get local machine name by socket.gethostname()
PORT = 50007 # The same port as used by the server,reserve a port for ur service reserve port
class ClientNode(object): #if you don't want to inherit NetworkUtility
def executor():
cn1 = NetworkUtility()
cn1.setupClientConnection(HOST, PORT)
cn1.sendMessage('Client 1: Hello')
print cn1.receiveMessage()
cn1.endConnection()
c = ClientNode()
c.executor()
如果它是在一個類中,那麼您可能會爲類實例傳遞一個'self' –