How do I run a Python command in Linux?

How do I run a Python command in Linux?
Answer
To use it to run a Linux command, your code should look like below.
  1. Sample Code using system() import os os.system(‘pwd’) os.system(‘cd ~’) os.system(‘ls -la’) …
  2. Writing a simple command using subprocess. …
  3. Writing a command with switches. …
  4. Storing the command output to a variable. …
  5. Saving the command output to a text file.
11 дек. 2020 г.
 

Tìm kiếm

Back
Top