method one,
os.system () will save the print value in the executable program and the return value of the main function, and will print the content to be printed during the execution
import os
main = "project1.exe"
r_v = os.system(main)
print (r_v )
Method Two,
commands.getstatusoutput () will save the print value in the executable program and the return value of the main function, but will not print the content to be printed during the execution
import subprocess
import os
main = "project1.exe"
if os.path.exists(main):
rc,out= subprocess.getstatusoutput(main)
print (rc)
print ('*'*10)
print (out)
Method three
popen () will save the print value in the executable program, but it will not save the return value of the main function, nor will it print the content to be printed during execution
import os
main = "project1.exe"
f = os.popen(main)
data = f.readlines()
f.close()
print (data)
In addition, the three methods mentioned above actually execute commands in python, so they are not only used to execute executable files, but also can be used to execute other instructions in the Linux system.