我有这段代码,我尝试在新线程中发送UDP数据报
import threading,socket address = ("localhost",9999) def send(sock): sock.sendto("Message",address) print "sent" s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) threading.Thread(target=send,args=(s)).start()
但是当我尝试将套接字作为函数的参数时,会抛出一个TypeError异常:
Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py",line 810,in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py",line 763,in self.__target(*self.__args,**self.__kwargs) TypeError: send() argument after * must be a sequence,not _socketobject
那意味着什么?