PHP processes json data from Python Post

Source: Internet
Author: User
: This article mainly introduces how PHP processes json data from Python Post. if you are interested in PHP tutorials, refer to it. Recently, Python has been used to process some json data, but some problems have been encountered during the process, so it is recorded.


1. Python Post json format data to the server:

I checked some materials, mostly like this:

__author__ = 'jiezhi'import urllibimport urllib2data = {'name': 'jiezhi', 'age': '24'}ret = urllib2.urlopen(url='http://jiezhiblog.com/test.php', data=urllib.urlencode(data))print ret.read()

However, php usually has the array type.

The following code is used after several times:

__author__ = 'jiezhi'import urllib2import jsondata = {'name': 'jiezhi', 'age': '24'}ret = urllib2.urlopen(url='http://jiezhiblog.com/test.php', data=json.dumps(data))print ret.read()

2. PHP problems

With the changed Python code, we found that no data was obtained from $ _ POST, so we used file_get_contents ("php: // input") to obtain the submitted data:

            

In this case, the submitted data can be obtained correctly.

Starting address: http://jiezhiblog.com/archives/366

The above describes how PHP processes json data from Python's Post, including some content, and hopes to help friends who are interested in PHP tutorials.

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.