您好,我尝试运行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
如何解决此错误?谢谢:)
答案 0 :(得分:2)
尝试一下:
from modules import HTTPHeaders
HTTPHeaders.HTTPHeaders(...)
您已导入模块本身,因此必须使用点符号来访问该功能。
或者像这样导入函数:
from modules.HTTPHeaders import HTTPHeaders
HTTPHeaders(...)