Alfred urlencode/urldecode插件
Alfred urlencode/urldecode插件
自己做个工具
老去搜索在线的urldecode工具,直接搞一个吧,更加方便了
直接上关键Script代码:😉
urlencode
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# author: xu3352<xu3352@gmail.com>
# desc: urlencode
## python2
# import sys
# import urllib
# result = urllib.quote('{query}');
# sys.stdout.write(result);
## python3
import sys
import urllib.parse
result = urllib.parse.urlencode({'': '{query}'})
sys.stdout.write( result[1:] )
urldecode
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# author: xu3352<xu3352@gmail.com>
# desc: urldecode
## python2
# import urllib
# import sys
# result = urllib.unquote('{query}').decode('utf8');
# sys.stdout.write(result);
## python3
from urllib.parse import unquote
import sys
result = unquote(unquote('{query}'))
sys.stdout.write(result);
下载资源:
参考:
- Url decode UTF-8 in Python
- python中的urlencode与urldecode
- Is there a way to substring a string in Python?
- URL Decode with Python 3
blog comments powered by Disqus