Python Analog HTTP POST request

Source: Internet
Author: User

Python version 2.7.9

Simulate a POST request

1 #coding:u82 ImportUrllib3 ImportUrllib24 5url = u"Http://192.168.84.182:8000/Home/GetTheme"6params = Urllib.urlencode ({'name':'Tom',' Age': 22})7 8req =Urllib2. Request (Url,params)9Response =Urllib2.urlopen (req)TenThe_page =Response.read () One PrintThe_page

When using URLLIB2 to simulate a POST request, the parameter is first represented by a dictionary and is encoded using Urllib.urlencode, which only supports this type of key-value pair

Add: Urllib and Urllib2 is not 2 is the upgrade version of 1, two libraries are project independent, do not misunderstand.

Python Analog HTTP POST request

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.