好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Python和php通信乱码问题解决方法

即使在urlencode之前str.decode(“cp936″).encode(“utf-8″)做了编码转换也是没用的。后来查询手册查到一个urllib.quote()函数,用此方法成功解决!
python端:

代码如下:


str = "中文"
str = urllib.quote(str.decode("cp936").encode("utf-8"))
postData = {}
postData['str'] = str
...post请求发送代码...


php端:

代码如下:


$str = urldecode($_POST['str'])
echo $str;


完美解决乱码问题!

查看更多关于Python和php通信乱码问题解决方法的详细内容...

  阅读:34次