Skip to content

Commit 58f88ff

Browse files
投稿: 模拟cmd2.5 — by ioo
1 parent 7dc35a0 commit 58f88ff

2 files changed

Lines changed: 162 additions & 2 deletions

File tree

script_library/index.json

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"format_version": 1,
3-
"data_version": 87,
4-
"updated": "2026-04-10T13:14:17.105Z",
3+
"data_version": 88,
4+
"updated": "2026-04-10T18:49:37Z",
55
"announcement": null,
66
"categories": [
77
{
@@ -1467,6 +1467,30 @@
14671467
"updated": null,
14681468
"status": "active",
14691469
"lines": 41
1470+
},
1471+
{
1472+
"id": "community_模拟cmd25__by_ioo",
1473+
"name": "模拟cmd2.5 — by ioo",
1474+
"name_en": "模拟cmd2.5 — by ioo",
1475+
"desc": "[投稿] 模拟cmd2.5 — by ioo",
1476+
"desc_en": "[投稿] 模拟cmd2.5 — by ioo",
1477+
"category": "basic",
1478+
"file": "scripts/basic/cmd2_5_mnrk35c0.py",
1479+
"thumbnail": null,
1480+
"version": 1,
1481+
"file_type": "py",
1482+
"author": "社区投稿",
1483+
"author_en": "社区投稿",
1484+
"tags": [
1485+
"community",
1486+
"basic"
1487+
],
1488+
"requires": [],
1489+
"min_app_version": "1.5.0",
1490+
"added": "2026-04-10",
1491+
"updated": null,
1492+
"status": "active",
1493+
"lines": 137
14701494
}
14711495
]
14721496
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# 欢迎使用 PythonIDE!如果觉得好用,请给个好评哦~
2+
# cmd简练版
3+
R = "" # 红
4+
G = "" # 绿
5+
Y = "" # 黄
6+
B = "" # 蓝
7+
C = "" # 青
8+
M = "" # 紫
9+
X = ""
10+
import os
11+
import dialogs
12+
import time
13+
def load():
14+
t="█"
15+
for i in range(51):
16+
if i*2<30:
17+
types=R
18+
elif i*2>30 and i*2<60:
19+
types=Y
20+
elif i*2>60:
21+
types=G
22+
print(f"\r|{types}{i * t}{X}|{(49 - i) * '-'}{i*2}%", end="\033[A")
23+
time.sleep(0.01)
24+
new_l = "\n"
25+
import json
26+
cmd = ""
27+
show = ">"
28+
file={"command.com":"bin,can't see",
29+
"io.sys":"bin,can't see",
30+
"msdos.sys":"bin,can't see",
31+
"ms.txt":"hello user!",
32+
"sys.txt":"看到这个的人我祝福他幸福快乐每一天",
33+
"thank.xz":"敢看嘛,其实是感谢使用"
34+
}
35+
print("DOS改版")
36+
print("输入help以了解命令")
37+
while True:
38+
39+
cmd = input(show).strip() #del " "
40+
if not cmd == new_l:
41+
# help
42+
if cmd.startswith("help"):
43+
print("echo 打印文字,如echo hello")
44+
print("echo on 开启提示符,echo off 关闭提示符")
45+
print("dir显示文件")
46+
print("type显示文件内容")
47+
print("del可以删除文件,无需路径")
48+
print("我自定义了文件的写入方式")
49+
print("add file-text")
50+
print("new file name")
51+
print("exit 退出程序")
52+
print("(del如果显示文件名就是删除成功)")
53+
#echo
54+
elif cmd.startswith("echo"):
55+
input_str = cmd[4:].lstrip()
56+
if input_str.startswith("on"):
57+
show = ">"
58+
elif input_str.startswith("off"):
59+
show = ""
60+
else:
61+
print(input_str)
62+
# exit
63+
elif cmd == "exit":
64+
65+
exit()
66+
elif cmd=="dir":
67+
print("file:")
68+
69+
for i in list(file):
70+
B=float('%.2f'%(len(str(file[i]))/1024))
71+
leng=32-len(str(i))
72+
print(f"- {i}"+f'%{leng}s'%(f'{B}KB'))
73+
print("file number:"+str(len(file)))
74+
elif cmd == "oaoa":
75+
print("91*10086=917826")
76+
# 在命令判断里加一段
77+
elif cmd.startswith("cls"):
78+
for I in range(1):
79+
print("\a")
80+
elif cmd.startswith("type"):
81+
print(file.get(cmd[5:],"无法找到此文件"))
82+
elif cmd.startswith("del "):
83+
if not cmd.endswith(".sys"):
84+
if file.pop(cmd[4:],False):
85+
86+
87+
88+
bool=True
89+
else:
90+
bool=False
91+
print("try del file:"+cmd[4:] if bool else "cannot find or del this file")
92+
elif cmd.startswith("add"):
93+
try:
94+
file[cmd[4:]]+=input(">>text")
95+
except:
96+
file[cmd[4:]]=input(">>text")
97+
elif cmd.startswith("new"):
98+
name=cmd[4:]
99+
text=input(">>text")
100+
file[name]=text
101+
elif cmd.startswith("format"):
102+
file={}
103+
exit()
104+
# read 命令
105+
elif cmd.startswith('load'):
106+
print("loading...")
107+
108+
load()
109+
print("\n")
110+
with open("dosfile.json", "r", encoding="utf-8") as f:
111+
file = json.load(f)
112+
elif cmd.startswith("save"):
113+
print("saving...")
114+
load()
115+
print("\n")
116+
with open("dosfile.json", "w", encoding="utf-8") as f:
117+
json.dump(file, f, ensure_ascii=False, indent=2)
118+
elif cmd.startswith("ui"):
119+
if dialogs.list_dialog("选择一个操作",["continue"])=="continue":
120+
continue
121+
else:
122+
continue
123+
124+
elif cmd.startswith("delt"):
125+
inp=input("此操作可能会影响到你的文件,是否继续(n/y)")
126+
if inp=="y":
127+
try:
128+
os.remove(cmd[5:])
129+
print("成功")
130+
except:
131+
print("失败")
132+
continue
133+
else:
134+
135+
dialogs.alert(f"'{cmd}' 不是内部或外部命令,也不是可运行的程序")
136+

0 commit comments

Comments
 (0)