【发布时间】:2014-07-09 20:23:57
【问题描述】:
具体来说,我想要一个 Python 脚本,它接受来自用户的字符串并将该字符串解释为终端中的命令。换句话说,我的脚本应该可以按如下方式使用:
python testScript.py "command -arg1 -arg2 -arg3"
输出应该如下:
command -arg1 -arg2 -arg3
使用 3 个参数执行命令:arg1、arg2 和 arg3。
即,
python testScript.py "ls -lah"
输出当前目录的权限。
同样,
python testScript.py "/testarea ls -lah"
会输出目录的权限,“/testarea”
有什么建议或模块吗?
【问题讨论】: