Python 7,Python 의 명령 행 프롬프트 구현

1994 단어 Pythonpythonlinux
다음 방법 을 사용 하면 python 을 사용 하여 명령 행 프롬프트 를 실현 할 수 있 습 니 다.
import os
# print(os.system('ls'))
# print(os.system('pwd'))
for i in range(1000):
    cmd = input('[test@ ~]$ ]')
    if cmd:
        if cmd == 'exit':
            print('logout')
            break
        else:
            print('run %s' %(cmd))
            #   shell  
            os.system(cmd)
    else:
        continue

좋은 웹페이지 즐겨찾기