What's the reverse of shlex.split?

后端 未结 5 1726
孤独总比滥情好
孤独总比滥情好 2020-12-08 02:16

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

5条回答
  •  -上瘾入骨i
    2020-12-08 02:38

    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 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.

提交回复
热议问题