Skip to content

Commit 314c9ea

Browse files
Merge pull request #98 from jinwandalaohu66/submission/cmd2_0_mnll1610
2 parents 6b57340 + 68d0114 commit 314c9ea

2 files changed

Lines changed: 124 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": 80,
4-
"updated": "2026-04-05T06:46:23.849Z",
3+
"data_version": 81,
4+
"updated": "2026-04-05T09:58:07Z",
55
"announcement": null,
66
"categories": [
77
{
@@ -1304,6 +1304,30 @@
13041304
"updated": null,
13051305
"status": "active",
13061306
"lines": 97
1307+
},
1308+
{
1309+
"id": "community_模拟cmd20__by_ioo",
1310+
"name": "模拟cmd2.0 — by ioo",
1311+
"name_en": "模拟cmd2.0 — by ioo",
1312+
"desc": "[投稿] 模拟cmd2.0 — by ioo",
1313+
"desc_en": "[投稿] 模拟cmd2.0 — by ioo",
1314+
"category": "basic",
1315+
"file": "scripts/basic/cmd2_0_mnll1610.py",
1316+
"thumbnail": null,
1317+
"version": 1,
1318+
"file_type": "py",
1319+
"author": "社区投稿",
1320+
"author_en": "社区投稿",
1321+
"tags": [
1322+
"community",
1323+
"basic"
1324+
],
1325+
"requires": [],
1326+
"min_app_version": "1.5.0",
1327+
"added": "2026-04-05",
1328+
"updated": null,
1329+
"status": "active",
1330+
"lines": 99
13071331
}
13081332
]
13091333
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# 欢迎使用 PythonIDE!如果觉得好用,请给个好评哦~
2+
# cmd简练版
3+
R = "" # 红
4+
G = "" # 绿
5+
Y = "" # 黄
6+
B = "" # 蓝
7+
C = "" # 青
8+
M = "" # 紫
9+
X = ""
10+
new_l = "\n"
11+
import json
12+
cmd = ""
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+
}
21+
print("DOS改版")
22+
print("输入help以了解命令")
23+
while True:
24+
25+
cmd = input(show).strip() #del " "
26+
if not cmd == new_l:
27+
# help
28+
if cmd.startswith("help"):
29+
print("echo 打印文字,如echo hello")
30+
print("echo on 开启提示符,echo off 关闭提示符")
31+
print("dir显示文件")
32+
print("type显示文件内容")
33+
print("del可以删除文件,无需路径")
34+
print("我自定义了文件的写入方式")
35+
print("add file-text")
36+
print("new file name")
37+
print("exit 退出程序")
38+
print("(del如果显示文件名就是删除成功)")
39+
#echo
40+
elif cmd.startswith("echo"):
41+
input_str = cmd[4:].lstrip()
42+
if input_str.startswith("on"):
43+
show = ">"
44+
elif input_str.startswith("off"):
45+
show = ""
46+
else:
47+
print(input_str)
48+
# exit
49+
elif cmd == "exit":
50+
51+
exit()
52+
elif cmd=="dir":
53+
print("file:")
54+
55+
for i in list(file):
56+
B=float('%.2f'%(len(str(file[i]))/1024))
57+
leng=32-len(str(i))
58+
print(f"- {i}"+f'%{leng}s'%(f'{B}KB'))
59+
print("file number:"+str(len(file)))
60+
elif cmd == "oaoa":
61+
print("91*10086=917826")
62+
# 在命令判断里加一段
63+
elif cmd.startswith("cls"):
64+
for I in range(1):
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+
elif cmd.startswith("format"):
88+
file={}
89+
exit()
90+
# read 命令
91+
elif cmd.startswith('load'):
92+
with open("dosfile.txt", "r", encoding="utf-8") as f:
93+
file = json.load(f)
94+
elif cmd.startswith("save"):
95+
with open("dosfile.txt", "w", encoding="utf-8") as f:
96+
json.dump(file, f, ensure_ascii=False, indent=2)
97+
else:
98+
print(f"'{cmd}' 不是内部或外部命令,也不是可运行的程序")

0 commit comments

Comments
 (0)