url的编码与解码
python中
from urllib import parse
print(parse.quote('上海')) # %E4%B8%8A%E6%B5%B7
print(parse.unquote('%E4%B8%8A%E6%B5%B7')) # 上海
php中
编码
<?php
$url = "http://example.com/search?query=Hello World & PHP";
$encodedUrl = urlencode($url);
echo $encodedUrl;
// 输出:http%3A%2F%2Fexample.com%2Fsearch%3Fquery%3DHello+World+%26+PHP
?>
解码
<?php
$encodedUrl = "http%3A%2F%2Fexample.com%2Fsearch%3Fquery%3DHello+World+%26+PHP";
$decodedUrl = urldecode($encodedUrl);
echo $decodedUrl;
// 输出:http://example.com/search?query=Hello World & PHP
?>``