Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我可以简单地通过属性访问 POST 请求的标头的do_POST()方法中。但我找不到用于访问消息正文的类似属性。那我该怎么做呢?BaseHTTPRequestHandlerself.headers
do_POST()
BaseHTTPRequestHandler
self.headers
您可以通过以下方法访问 POST 正文do_POST:
do_POST
对于蟒蛇 2
content_len = int(self.headers.getheader('content-length', 0))
对于蟒蛇 3
content_len = int(self.headers.get('Content-Length'))
然后读取数据
post_body = self.rfile.read(content_len)