代码部分
1.在指定conda下运行某行命令
1 2 3
| import subprocess command_1 = (r'cmd.exe /c conda run -n svc python D:\user\PycharmProjects\ai_video\my_resample.py --in_dir D:\user\PycharmProjects\ai_video\original_music --out_dir2 D:\user\PycharmProjects\ai_video\resample_original_music') subprocess.run(command_1, shell=True, check=True)
|
2.如果需要用到管理员权限
1 2 3 4 5 6 7 8 9 10
| import ctypes def is_admin(): try: return ctypes.windll.shell32.IsUserAnAdmin() except: return False if is_admin(): else: ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
|
友情链接
1.https://zhuanlan.zhihu.com/p/91342640 subprocess的简单介绍
2.https://blog.csdn.net/m0_66922250/article/details/133928172 不同环境的串联