Jupyter 简明教程
IPython - System Commands
如果输入单元格中的语句以惊叹号 (!) 开头,则它会被当作底层操作系统的系统命令。例如, !ls (适用于 Linux)和 !dir (适用于 Windows)会显示当前目录的内容
If the statement in the input cell starts with the exclamation symbol (!), it is treated as a system command for underlying operating system. For example, !ls (for linux) and !dir (for windows) displays the contents of current directory

系统命令的输出还可以像下面所示分配给 Python 变量 −
The output of system command can also be assigned to a Python variable as shown below −

该变量存储无颜色的输出,并在换行符处拆分。
The variable stores output without colors and splits at newline characters.
还可以将 Python 变量或表达式和系统命令调用结合起来。大括号 {} 中的变量可以内嵌在命令文本中。观察以下示例 −
It is also possible to combine Python variables or expressions with system command calls. Variable in curly brackets {} can be embedded in command text. Observe the following example −

以下是另一个示例,它说明在 Python 变量前加上 $ 也能实现相同的结果。
Here is another example to understand that prefixing Python variable with $ also achieves the same result.
