【发布时间】:2010-11-01 07:59:27
【问题描述】:
Python 标准库中是否有任何东西可以正确解析/解析字符串以在 shell 命令中使用?我正在寻找 perl 的 String::ShellQuote::shell_quote 的 python 模拟:
$ print String::ShellQuote::shell_quote("hello", "stack", "overflow's", "quite", "cool")
hello stack 'overflow'\''s' quite cool
而且,更重要的是,一些可以反向工作的东西(获取一个字符串并将其分解为一个列表)。
【问题讨论】: