Skip to content

Commit d5f340c

Browse files
[投稿] 添加脚本: 模拟cmd1.0 — by ioo
1 parent bf22f98 commit d5f340c

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# 欢迎使用 PythonIDE!如果觉得好用,请给个好评哦~
2+
# cmd简练版
3+
R = "\033[91m" # 红
4+
G = "\033[92m" # 绿
5+
Y = "\033[93m" # 黄
6+
B = "\033[94m" # 蓝
7+
C = "\033[96m" # 青
8+
M = "\033[95m" # 紫
9+
X = "\033[0m"
10+
new_l = "\n"
11+
cmd = ""
12+
13+
show = ">"
14+
file={"command.com":"bin,can't see",
15+
"io.sys":"bin,can't see",
16+
"msdos.sys":"bin,can't see",
17+
"ms.txt":"hello user!",
18+
"sys.txt":"看到这个的人我祝福他幸福快乐每一天",
19+
"thank.xz":"敢看嘛,其实是感谢使用",
20+
"format.bat":"format"
21+
}
22+
print("DOS改版")
23+
24+
print("输入help以了解命令")
25+
while True:
26+
27+
cmd = input(show).strip() #del " "
28+
if not cmd == "\n":
29+
# help
30+
if cmd.startswith("help"):
31+
print("echo 打印文字,如echo hello")
32+
print("echo on 开启提示符,echo off 关闭提示符")
33+
print("dir显示文件")
34+
print("type显示文件内容")
35+
print("del可以删除文件,无需路径")
36+
print("我自定义了文件的写入方式")
37+
print("add file-text")
38+
print("new file name")
39+
print("exit 退出程序")
40+
print("(del如果显示文件名就是删除成功)")
41+
#echo
42+
elif cmd.startswith("echo"):
43+
input_str = cmd[4:].lstrip()
44+
if input_str.startswith("on"):
45+
show = ">"
46+
elif input_str.startswith("off"):
47+
show = ""
48+
else:
49+
print(input_str)
50+
# exit
51+
elif cmd == "exit":
52+
53+
exit()
54+
elif cmd=="dir":
55+
print(R+"file:")
56+
print(B)
57+
for i in list(file):
58+
print(" "+i)
59+
print(G+"file number:"+str(len(file)));print(X)
60+
elif cmd == "oaoa":
61+
print(G+"91*10086=917826");print(X)
62+
# 在命令判断里加一段
63+
elif cmd.startswith("cls"):
64+
for I in range(1145):
65+
print("\a")
66+
elif cmd.startswith("type"):
67+
print(file.get(cmd[5:],"无法找到此文件"))
68+
elif cmd.startswith("del"):
69+
if not cmd.endswith(".sys"):
70+
if file.pop(cmd[4:],False):
71+
72+
73+
74+
bool=True
75+
else:
76+
bool=False
77+
print("try del file:"+cmd[4:] if bool else "cannot find or del this file")
78+
elif cmd.startswith("add"):
79+
try:
80+
file[cmd[4:]]+=input(">>text")
81+
except:
82+
file[cmd[4:]]=input(">>text")
83+
elif cmd.startswith("new"):
84+
name=cmd[4:]
85+
text=input(">>text")
86+
file[name]=text
87+
else:
88+
if cmd=="\n":
89+
continue
90+
else:
91+
92+
print(f"'{cmd}' 不是内部或外部命令,也不是可运行的程序")

0 commit comments

Comments
 (0)