TypeError: 'module' object is not callable

前端 未结 11 1826
耶瑟儿~
耶瑟儿~ 2020-11-22 12:06
File \"C:\\Users\\Administrator\\Documents\\Mibot\\oops\\blinkserv.py\", line 82, in __init__
    self.serv = socket(AF_INET,SOCK_STREAM)
TypeError: \'module\' objec         


        
11条回答
  •  耶瑟儿~
    2020-11-22 12:36

    It seems like what you've done is imported the socket module as import socket. Therefore socket is the module. You either need to change that line to self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM), as well as every other use of the socket module, or change the import statement to from socket import socket.

    Or you've got an import socket after your from socket import *:

    >>> from socket import *
    >>> serv = socket(AF_INET,SOCK_STREAM)
    >>> import socket
    >>> serv = socket(AF_INET,SOCK_STREAM)
    Traceback (most recent call last):
      File "", line 1, in 
    TypeError: 'module' object is not callable
    

提交回复
热议问题