如何从python中选择cmd路径?


0

我有一个类似这样的代码:

file = open('cmd.bat')
file.write('cmd.exe')
file.close()

import os
os.runfile('cmd.exe')

当它运行命令提示符时,它将在保存程序的目录中运行(在C:\ Users \ Me \ OneDrive \ Desktop \ Python \ Programs \ CMD launcher \ cmd.bat的某个位置)。如何在C:\中打开命令提示符而不手动键入cd ..6次?


3
你试过打字cd c:\吗?
DavidPostill
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.