Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. import subprocess
  2. import os
  3. class Terminal:
  4.  
  5.     def __init__(self):
  6.         pass
  7.  
  8.     def execute(self, command):
  9.         command = command.split()
  10.         if "cd" in command:
  11.             os.chdir(command[1])
  12.             return ""
  13.         return subprocess.check_output(command).decode()
  14.  
  15. print("Terminal Emulator")
  16.  
  17. term = Terminal()
  18. while True:
  19.     try:
  20.         print(term.execute(input(f"{os.getcwd()}->")))
  21.     except:
  22.         print("Ошибка. Попробуйте далее")
  23.         continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement