「Python」os.system(command)
来源:互联网 发布:大数据用什么语言最好 编辑:程序博客网 时间:2024/06/04 19:34
1、Python2的文档os.system(command)
2、下面是文档的翻译和理解:
Execute the command (a string) in a subshell.
在subshell执行命令,该命令是一个字符串。比如:新建一个python文件,输入下面两句话,然后执行这个文件。
import osos.system('nvidia-detector')执行之后得到返回“none”。内容换成以下两句话。
import osos.system('nvidia-smi')执行之后得到返回一个表格,表格里面是关于GPU的信息。与直接在终端中输入nvidia-smi等价。
This is implemented by calling the Standard C function system()
, and has the same limitations.
解释具体的调用。命令通过调用system()而执行。
Changes to sys.stdin etc. are not reflected in the environment of the executed command.
解释“limitations”?
On Unix, the return value is the exit status of the process encoded in the format specified for wait().
On Windows, the return value is that returned by the system shell after running command, given by the Windows environment variable COMSPEC: on command.comsystems (Windows 95, 98 and ME) this is always 0; on cmd.exe systems (Windows NT, 2000 and XP) this is the exit status of the command run; on systems using a non-native shell, consult your shell documentation.
The subprocess module provides more powerful facilities for spawning new processes and retrieving their results; using that module is preferable to using this function. See the Replacing Older Functions with the subprocess Module section in the subprocess documentation for some helpful recipes.
Availability: Unix, Windows.
后面的信息不想翻译了,总之,在Ubuntu的终端或者在Windows的CMD执行的命令,在Python文件中可以调用。
- 「Python」os.system(command)
- Python os.system(command),这样执行的command命令,和主程序是异步的吗?
- python os.popen os.system
- Python os.system
- python os.system("cd")
- python os.system
- python os.system(command)函数的返回值 与 linux命令返回值的关系
- python os.system os.popen 区别
- python os.popen与os.system区别
- python os.system os.popen 区别
- python os.system()和os.popen()
- python os.popen()和os.system()区别
- python中os.popen, os.system()区别
- python os.system() 空格处理
- 关于python中os.system,os.popen,os.comands
- python中os.system()的返回值
- Python中os.system()的返回值
- python 线程中使用os.system
- 求1到100之间的素数
- Git使用教程
- Mysql 修改root密码,并设置远程访问
- Eclipse怎么使用lombok?
- 深入理解Java虚拟机(五)类加载机制
- 「Python」os.system(command)
- 句柄再谈
- 初学易语言,所要准备些什么书籍与资料
- 基本数据类型
- 单调栈+STL——51nod1952 栈
- 图形学(5)多边形的扫描转换(下)
- ActionMode去掉返回箭头
- 数据结构_顺序表
- QDirModel