Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

How can I call an external command (as if I'd typed it at the Unix shell or Windows command prompt) from within a Python script?

1 Answer

0 votes
by (106k points)
edited by

For calling an external command in Python you should look at the subprocess module in the standard library see the code below:-

import subprocess 

subprocess.run(["ls", "-l"])

To know more about this you can have a look at the following video tutorial:-

Related questions

+1 vote
2 answers
0 votes
3 answers
+7 votes
1 answer
0 votes
4 answers

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...