Python uses post to submit data

Source: Internet
Author: User

Python uses post to submit data

This article mainly introduces python's method of submitting data through post, which involves Python's skills in using post to transmit data. For more information, see

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

#-*-Coding: cp936 -*-

Import urllib2

Import urllib

Def postHttp (name = None, tel = None, address = None,

Price = None, num = None, paytype = None,

Posttype = None, other = None ):

Url = "http://www.xxx.com/dog.php"

# Define the data to be submitted

Postdata = dict (name = name, tel = tel, address = address, price = price,

Num = num, paytype = paytype, posttype = posttype, other = other)

# Url Encoding

Postdata = urllib. urlencode (postdata)

# Enable cookie

Request = urllib2.Request (url, postdata)

Response = urllib2.urlopen (request)

Print response

Call the function:

The Code is as follows:

PostHttp ('name', 'telephony ', 'address', '000000', '1', 'cash on delivery', 'EMS domestic postal express delivery ', 'hunger and ears rabbit-International brands ')

I hope this article will help you with Python programming.

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.