我之前自己瞎写了一个,你看看行不import os
import subprocess
ml = ''
os.chdir("C:\\Users")
while ml != 'exit':
ml = input(os.getcwd() + '> ')
if 'cd' in ml:
try:
os.chdir(ml.split('cd ')[1])
except FileNotFoundError as reason:
print(reason)
continue
except:
resp = subprocess.Popen(ml + ' /?', shell = True,stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
print(resp[0].decode('gbk'), resp[1].decode('gbk'))
elif ml[:-1].isalpha() and len(ml) == 2 and ml[-1] == ':':
os.chdir(ml[:-1] + ':\\')
else:
resp = subprocess.Popen(ml, shell = True,stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
print(resp[0].decode('gbk'), resp[1].decode('gbk'))
|