Python executes commands in the specified directory

novice to python,
enter the specified directory to execute a command

see a solution. What I understand is that the semicolon is preceded by entering the folder, followed by the execution of the command, but executed in windows

import os
  os.system("cd D:/ANDROID/test1/HBuilder-Integrate-AS;./gradle assembleRelease")






import os
os.system("cd ~/cstudy;./sdkTest")

problem solving:
1.1l boss"s solution is the best. Fully applicable
2. You can also use os.system ("cd:./xxxx/xxx & & gradle assembleRelease"). The disadvantage is that there is a problem across the drive


Please use subprocess.check_call, instead, such as

subprocess.check_call('gradle assembleRelease', shell=True, cwd='D:/ANDROID/test1/HBuilder-Integrate-AS')
Menu