本站改版新增arduino频道
def url_decode(url):
pos = 0
byts = b''
while pos < len(url):
ch = url[pos]
if ch == '+':
byts = byts + b' '
pos = pos + 1
continue
elif ch != '%':
# ascii code
byts = byts + ch.encode('utf8')
pos = pos + 1
continue
else :
# no ascii code
hex = url[pos+1:pos+3]
byts = byts + bytes([int(hex,16)])
pos = pos + 3
continue
return byts.decode('utf8')
print(url_decode("http://api.b4.xxxx.com/pdd/goods?k=%E7%BB%83%E4%B9%A0%E5%AD%97%E5%B8%96"))
Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号
执行时间: 0.0093469619750977 seconds