比如 admin 在用 urllib 的 quote 时还是 admin ,希望能够对非特殊字符也进行 URL 编码,变为%61%64%6D%69%6E
Google 的好半天没有查到,求高手解答!
Google 的好半天没有查到,求高手解答!
|
KisesyApr 5, 2017
1
你抄一下官方库代码, 自己写个函数把这个限制去掉不就好了, 就几句代码
|
|
2
re.sub(r'.', lambda m: '%%%s' % m.group(0).encode('hex').upper(), 'admin')
|
|
KisesyApr 5, 2017
3
a = b'admin'
b = ''.join('%{:02X}'.format(x) for x in a) print(b) |
|
LuckyrayApr 5, 2017
4
对英文字符也编码的好处或者用处是啥?
|
|
lrxiaoApr 5, 2017
5
urllib2.quote
|
|
glasslionApr 5, 2017
6
admin ? 你该不会是想通过 url encode 的方式 来搞 sql 防注入之类的 东东吧? 慎之。
|