我在一个字符串变量中有一个命令行(这不是我程序的参数,我从别的地方得到的):
cmd_line = "app.exe --a value -b \"this is a quoted string\"";
如何将此命令行转换为数组?
res = ["app.exe", "--a", "value", "-b", "this is a quoted string"]
有个winapi函数CommandLineToArgvW . Python 中有等效项吗?
最佳答案
shlex.split()
正是这样做的:https://docs.python.org/2/library/shlex.html
关于python - 如何将命令行字符串转换为数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33508059/