如何在命令行中呈现百分比编码? [英] How can I render percent encoding in command line?

查看:80
本文介绍了如何在命令行中呈现百分比编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常有一个字符串百分比编码,例如%D1%84%D0%B0%D0%B9%D0%BB ,如果它是一部分链接,现代的浏览器会正确地呈现为файл

I often have a string "percent encoded", such as %D1%84%D0%B0%D0%B9%D0%BB, which, if it's part of a link, a modern browser would properly render as файл.

我想知道:是否有一种简单的方法可以通过使用 sed 或其他命令行工具,呈现一个具有百分比编码(或只是百分比编码的输入字符串)的文本文件?

I wonder: is there a simple way to "render" a text file with percent encoding (or simply an input string in percent encoding) as the one above by using sed or other command line tool?

另请参见与此相关的内容问题

推荐答案

Python可以使用 urllib.unquote_plus

Python can do this using urllib.unquote_plus:

#!/usr/bin/env python2

import sys
import urllib

print urllib.unquote_plus("%D1%84%D0%B0%D0%B9%D0%BB")

您可以设置别名以使用快速cli命令:
http://ruslanspivak.com/2010/06/02/urlencode-and-urldecode-from-命令行/

You can set an alias to have a quick cli command: http://ruslanspivak.com/2010/06/02/urlencode-and-urldecode-from-a-command-line/

这篇关于如何在命令行中呈现百分比编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆