python url转码_URL转码,encodeURI,encodeURIComponent — 在线工具

一、encodeURIComponent()

1.encodeURIComponent()方法的使用

语法:encodeURIComponent(URIstring)

参数:URIstring,必需。一个字符串,含有 URI 组件或其他要编码的文本。

2.encodeURIComponent()测试

测试

document.write(encodeURIComponent("https://www.sojson.com/encodeurl.html?我是个中文参数"))

document.write("
")

document.write(encodeURIComponent(",/?:@&=+$#"))

结果

http%3A%2F%2Fwww.sojson.com%2Fencodeurl.html%3F%E6%88%91%E6%98%AF%E4%B8%AA%E4%B8%AD%E6%96%87%E5%8F%82%E6%95%B0

%3Cbr%20%2F%3E

%2C%2F%3F%3A%40%26%3D%2B%24%23

二、encodeURI()测试

测试

document.write(encodeURI("https://www.sojson.com/encodeurl.html?我是个中文参数"))

document.write("
")

document.write(encodeURI(",/?:@&=+$#"))

结果

https://www.sojson.com/encodeurl.html?%E6%88%91%E6%98%AF%E4%B8%AA%E4%B8%AD%E6%96%87%E5%8F%82%E6%95%B0

%3Cbr%20/%3E

,/?:@&=+$#

三、 encodeURIComponent() 函数 与 encodeURI() 函数的区别

请注意 encodeURIComponent() 函数 与 encodeURI() 函数的区别之处,前者假定它的参数是 URI 的一部分(比如协议、主机名、路径或查询字符串)。因此 encodeURIComponent() 函数将转义用于分隔 URI 各个部分的标点符号。

广告 for Goolge

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值