Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
类型错误:';模块';对象不可调用Python3_Python_Python 3.x - Fatal编程技术网

类型错误:';模块';对象不可调用Python3

类型错误:';模块';对象不可调用Python3,python,python-3.x,Python,Python 3.x,你好,我尝试运行run.py,但收到一条错误消息 Run.py from modules import HTTPHeaders site = "https://google.com" HTTPHeaders(site, _verbose=True) HTTPHeaders.py import dns import dns.resolver def HTTPHeaders(site, _verbose=None): if _verbose != None: try:

你好,我尝试运行run.py,但收到一条错误消息

Run.py

from modules import HTTPHeaders
site = "https://google.com"
HTTPHeaders(site, _verbose=True)
HTTPHeaders.py

import dns
import dns.resolver
def HTTPHeaders(site, _verbose=None):
if _verbose != None:
    try:
        r = http.request('GET', "http://"+site)
    except:
        pass

    if (r.status == 200):
        print("HTTP/1.1 200 OK")
    else:
        print(r.status)
    try:
        print("Content-Type : "+r.headers['Content-Type'])
    except:
        pass
    try:
        print("Server : "+r.headers['Server'])
    except:
        pass
    try:
        print("Set-Cookie : "+r.headers['Set-Cookie'])
    except:
        pass
我的错误:

    TypeError: 'module' object is not callable
如何修复此错误?谢谢:)

试试这个:

从模块导入HttpHeader
HTTPHeaders.HTTPHeaders(…)
您导入了模块本身,因此必须使用点符号访问函数

或者像这样导入函数:

from modules.HTTPHeaders导入HTTPHeaders
HttpHeader(…)

错误清楚地表明,您正在尝试调用导入的模块,这是不可能的。您打算做的是从这个模块中调用同名函数:
HTTPHeaders.HTTPHeaders(site,\u verbose=True)
对不起,我更改了答案的文本。注意,现在它非常正确:)