URL编码在线工具



关于URL编码在线工具:

这个在线URL编码工具可以帮助您将一个输入字符串转换为URL格式字符串.

为什么需要使用URL编码?

HTTP GET请求通常包含参数. 但是, 参数中一部分字符可能会产生歧义. 要解决此问题,浏览器将自动用%接着2个数字用来替换不安全的ASCII字符例如'&'将被'%26'替换, 空格将被'%20'替换.

URL编码转换表:

! # $ & ' ( ) * + , / : ; = ? @ [ ]
%21 %23 %24 %26 %27 %28 %29 %2A %2B %2C %2F %3A %3B %3D %3F %40 %5B %5D

comic url encode

用Python计算字符串的URL编码:

  1. import urllib.parse
  2.  
  3. def url_encode(input_str):
  4. output_msg = urllib.parse.quote(input_str).strip()
  5. return output_msg

用Java计算字符串的URL编码:

  1. import java.io.UnsupportedEncodingException;
  2. import java.net.URLEncoder;
  3.  
  4. public class URL {
  5. public static String url_encode(String url) throws UnsupportedEncodingException {
  6. return URLEncoder.encode(url, "UTF-8");
  7. }
  8.  
  9. public static void main(String[] args) throws UnsupportedEncodingException {
  10. String result = url_encode("https://maps.google.com/maps?ll=37.413323,-122.081267&z=11&q=Mountain View California USA");
  11. System.out.println(result);
  12. }
  13. }
  14.  
  15. -------------------
  16. https%3A%2F%2Fmaps.google.com%2Fmaps%3Fll%3D37.413323%2C-122.081267%26z%3D11%26q%3DMountain+View+California+USA