How do I replace os.system("mkdir " + _testName)
with subprocess.call()
in Python?
mkdir
is the unix command I want to run. _testName
is a variable that is defined in the python script.
without subprocess: os.mkdir
with subprocess:
subprocess.call(['mkdir',_testName])
Or, if you want to make sure you were successful:
subprocess.check_call(['mkdir', _testName])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.