English 中文(简体)
IPython - System Commands
  • 时间:2024-09-17

IPython - System Commands


Previous Page Next Page  

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 pnux) and !dir (for windows) displays the contents of current directory

Exclamation Symbol (!) Command

The output of system command can also be assigned to a Python variable as shown below −

Output of system command

The variable stores output without colors and sppts at newpne characters.

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 −

System Command Calls

Here is another example to understand that prefixing Python variable with $ also achieves the same result.

Prefixing Python Variable Advertisements