我无法获得导入请求。当我使用终端时,它正在工作,但我现在正试图在我的网站上完成同样的事情。它是一个托管在hostgator上的站点,我的python的其余部分正常工作。奇怪的是我可以导入json并且工作正常,但不是请求。基本上,该站点在导入时停止处理。有什么想法吗?
以下是我的代码
print('<br/>')
print('import sys')
import sys
print('<br/>')
print(sys.modules)
print('<br/>')
print('import platform')
import platform
print('<br/>')
print(sys.modules)
print('<br/>')
print('import json')
import json
print('<br/>')
print(sys.modules)
print('<br/>')
print('import requests')
import requests
print('<br/>')
print(sys.modules)
代码的输出如下:
导入sys
{'copy_reg':,'encodings':,'site':,' builtin ':,' main ':,'encodings.encodings':无,'abc':,'posixpath':,'errno':,'encodings.codecs':无,'_ abcoll':,'types':,'_ codecs':,'_ warnings':,'genericpath':,' stat':,'zipimport':,'编码。内置':无,'警告':,'UserDict':,'encodings.ascii':,'sys':,'pwd': ,'codecs':,'os.path':,'signal':,'linecache':,'posix':,'encodings.aliases':,'exceptions':,'abrt_exception_handler':,'os':}
导入平台
{'copy_reg':,'sre_compile':,'_ sre':,'encodings':,'site':,' builtin ':,' main ':','encodings.encodings':无,'abc':,'posixpath':,'re':,'errno':,'encodings.codecs':无,'sre_constants':,'platform':,' _abcoll':,'types':,'_ codecs':,'_ warnings':,'genericpath':,'stat':,'zipimport':,'encodings。 builtin ':无,' string':,'warnings':,'UserDict':,'encodings.ascii':,'sys':,'pwd':,'codecs':,'os.path':,'strop':,'signal ':,'linecache':,'posix':,'encodings.aliases':,'exceptions':,'sre_parse':,'abrt_exception_handler':,'os':}
导入json
{'json.decoder':,'copy_reg':,'sre_compile':,'_ sre':,'encodings':,'site':,' builtin ':','< strong> main ':,'encodings.encodings':无,'json.math':无,'json.sre_constants':无,'json.sre_compile':无,'abc':,'posixpath' :,'re':,'errno':,'_ json':,'encodings.codecs':无,'sre_constants':,'platform':,'json':,'_ abcoll':,'types':, '_codecs':,'_warnings':,'math':,'json._json':无,'genericpath':,'stat':,'zipimport':,'编码。内置' :None,'string':,'warnings':,'UserDict':,'encodings.ascii':,'json.json':无,'json.sys':无,'sys':,'pwd': ,'codecs':,'json.encoder':,'os.path':,'strop':,'json.re':无,'信号':,'json.scanner':,'linecache':,, 'json.sre_parse':无,'posix':,'encodings.aliases':,'exceptions':,'sre_parse':,'abrt_exception_handler':,'os':}
导入请求