我正在嘗試遵循有關創建和托管 HTTP 代理的教程。當我嘗試安裝模塊時,它失敗了。(SimpleHTTPServer 和 SocketServer)
使用的教程:https ://levelup.gitconnected.com/how-to-build-a-super-simple-http-proxy-in-python-in-just-17-lines-of-code-a1a09192be00
輸出:
pip install SimpleHTTPServer
ERROR: Could not find a version that satisfies the requirement SimpleHTTPServer (from versions: none)
ERROR: No matching distribution found for SimpleHTTPServer
pip install SocketServer
ERROR: Could not find a version that satisfies the requirement SocketServer (from versions: none)
ERROR: No matching distribution found for SocketServer
當我嘗試運行程式時:
Traceback (most recent call last):
File "simpleServer.py", line 1, in <module>
import SocketServer
ModuleNotFoundError: No module named 'SocketServer'
uj5u.com熱心網友回復:
這些是 LeopardShark 提到的標準庫的模塊。您可以直接將它們匯入到您的代碼中,而無需使用 pip 安裝它們。
您可以在此處找到標準庫隨附的完整模塊串列:https ://docs.python.org/3/library/
此外,您詢問的特定模塊在 Python3 中已重命名:
注意 SimpleHTTPServer 模塊已合并到 Python 3 中的 http.server 中。
基于模塊的檔案:https ://docs.python.org/2/library/simplehttpserver.html
基本上,您只需要這樣做:
import http.server
import socketserver
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/416587.html
標籤:
上一篇:React在事件中重復渲染
