How do I execute a program or call a system command?
@lebyy▲ 0 net votes
Problem: How do I call an external command within Python as if I had typed it in a shell or command prompt? Fix (from the top answer): Use subprocess.run : import subprocess subprocess.run(["ls", "-l"]) Another common way is os.system but you shouldn't use it because it is unsafe if any parts of the command come from outside your program or can contain spaces or other special characters, also subprocess.run is generally more flexible (you can get…