用python写一个dos
下面是一个简单的Python脚本,可以模拟DOS命令行的基本功能:
import os
while True:
command = input(">> ")
if command.lower() == "exit":
break
try:
output = os.popen(command).read()
print(output)
except:
print("Command not found.")
这个脚本会进入一个无限循环,等待用户输入命令。用户可以输入任何DOS命令,脚本会执行该命令并显示输出结果。如果用户输入"exit",循环会被终止,脚本退出。
请注意,这个脚本仅仅是一个简单的示例,可能不支持所有的DOS命令和功能。在使用时,请小心并只执行你信任的命令。
原文地址: https://www.cveoy.top/t/topic/hPSO 著作权归作者所有。请勿转载和采集!