Python and PHP communication garble problem solution
- 2020-04-02 13:33:11
- OfStack
It is useless to encode STR. Decode (" cp936 "). Encode (" utf-8 ") before urlencode. Later query manual found a urllib.quote() function, with this method successfully solved!
Python side:
The PHP side:
Perfect solution to the problem of garbled code!
Python side:
str = " Chinese "
str = urllib.quote(str.decode("cp936").encode("utf-8"))
postData = {}
postData['str'] = str
...post Request sending code ...
The PHP side:
$str = urldecode($_POST['str'])
echo $str;
Perfect solution to the problem of garbled code!