本文介绍了shlex.split 的反面是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何反转 shlex.split?也就是说,我怎样才能获得一个带引号的字符串,它会类似于 Unix shell",给定我希望引用的list 字符串?

How can I reverse the results of a shlex.split? That is, how can I obtain a quoted string that would "resemble that of a Unix shell", given a list of strings I wish quoted?

我发现了一个 Python 错误,并在此处提出了相应的功能请求.

I've located a Python bug, and made corresponding feature requests here.

推荐答案

我们现在 (3.3) 有一个 shlex.quote 函数.pipes.quote 移动和记录的不是别的(使用 pipes.quote 的代码仍然可以工作).有关整个讨论,请参阅 http://bugs.python.org/issue9723.

We now (3.3) have a shlex.quote function. It’s none other that pipes.quote moved and documented (code using pipes.quote will still work). See http://bugs.python.org/issue9723 for the whole discussion.

subprocess.list2cmdline 是不应使用的私有函数.然而,它可以被移动到 shlex 并正式公开.另请参阅 http://bugs.python.org/issue1724822.

subprocess.list2cmdline is a private function that should not be used. It could however be moved to shlex and made officially public. See also http://bugs.python.org/issue1724822.

这篇关于shlex.split 的反面是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-09 12:43