1+ # 欢迎使用 PythonIDE!如果觉得好用,请给个好评哦~
2+ # cmd简练版
3+ R = "" # 红
4+ G = "" # 绿
5+ Y = "" # 黄
6+ B = "" # 蓝
7+ C = "" # 青
8+ M = "" # 紫
9+ X = ""
10+
11+ copy = ""
12+ import os
13+ import dialogs
14+ import time
15+ def load ():
16+ t = "█"
17+ for i in range (51 ):
18+ if i * 2 < 30 :
19+ types = R
20+ elif i * 2 > 30 and i * 2 < 60 :
21+ types = Y
22+ elif i * 2 > 60 :
23+ types = G
24+ print (f"\r |{ types } { i * t } { X } |{ (49 - i ) * '-' } { i * 2 } %" , end = "\033 [A" )
25+ time .sleep (0.01 )
26+ new_l = "\n "
27+ import json
28+ cmd = ""
29+ show = ">"
30+ file = {"command.com" :"bin,can't see" ,
31+ "io.sys" :"bin,can't see" ,
32+ "msdos.sys" :"bin,can't see" ,
33+ "ms.txt" :"hello user!" ,
34+ "sys.txt" :"看到这个的人我祝福他幸福快乐每一天" ,
35+ "thank.xz" :"敢看嘛,其实是感谢使用"
36+ }
37+ print ("DOS改版" )
38+ print ("输入help以了解命令" )
39+ while True :
40+
41+ cmd = input (show ).strip () #del " "
42+ if not cmd == new_l :
43+ # help
44+ if cmd .startswith ("help" ):
45+ print ("echo 打印文字,如echo hello" )
46+ print ("echo on 开启提示符,echo off 关闭提示符" )
47+ print ("dir显示文件" )
48+ print ("type显示文件内容" )
49+ print ("del可以删除文件,无需路径" )
50+ print ("我自定义了文件的写入方式" )
51+ print ("add file-text" )
52+ print ("new file name" )
53+ print ("exit 退出程序" )
54+ print ("alert text" )
55+ print ("(del如果显示文件名就是删除成功)" )
56+ #echo
57+ elif cmd .startswith ("echo" ):
58+ input_str = cmd [4 :].lstrip ()
59+ if input_str .startswith ("on" ):
60+ show = ">"
61+ elif input_str .startswith ("off" ):
62+ show = ""
63+ else :
64+ print (input_str )
65+ # exit
66+ elif cmd == "exit" :
67+ exit ()
68+ elif cmd == "dir" :
69+ print ("file:" )
70+
71+ for i in list (file ):
72+ B = float ('%.2f' % (len (str (file [i ]))/ 1024 ))
73+ leng = 32 - len (str (i ))
74+ print (f"- { i } " + f'%{ leng } s' % (f'{ B } KB' ))
75+ print ("file number:" + str (len (file )))
76+ elif cmd == "oaoa" :
77+ print ("91*10086=917826" )
78+ # 在命令判断里加一段
79+ elif cmd .startswith ("cls" ):
80+ for I in range (1 ):
81+ print ("\a " )
82+ elif cmd .startswith ("type" ):
83+ print (file .get (cmd [5 :],"无法找到此文件" ))
84+ elif cmd .startswith ("del " ):
85+ if not cmd .endswith (".sys" ):
86+ if file .pop (cmd [4 :],False ):
87+ kakimi = "jsjsjjzzkafjzlyrzkxyf"
88+ #上面这个string是猫踩的
89+ #处理误删文件
90+ bool = True
91+ else :
92+ bool = False
93+ print ("try del file:" + cmd [4 :] if bool else "cannot find or del this file" )
94+ elif cmd .startswith ("add" ):
95+ try :
96+ file [cmd [4 :]]+= input ("text>" )
97+ except :
98+ file [cmd [4 :]]= input ("text>" )
99+ elif cmd .startswith ("new" ):
100+ name = cmd [4 :]
101+ text = input ("text>" )
102+ file [name ]= text
103+ elif cmd .startswith ("format" ):
104+ file = {}
105+ exit ()
106+ # read 命令
107+ elif cmd .startswith ('load' ):
108+ print ("loading..." )
109+ load ()
110+ print ("\n " )
111+ with open ("dosfile.json" , "r" , encoding = "utf-8" ) as f :
112+ file = json .load (f )
113+ elif cmd .startswith ("save" ):
114+ print ("saving..." )
115+ load ()
116+ print ("\n " )
117+ with open ("dosfile.json" , "w" , encoding = "utf-8" ) as f :
118+ json .dump (file , f , ensure_ascii = False , indent = 2 )
119+ elif cmd .startswith ("ui" ):
120+ if dialogs .list_dialog ("选择一个操作" ,["continue" ])== "continue" :
121+ continue
122+ else :
123+ continue
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+ elif cmd .startswith ("alert" ):
134+ dialogs .alert (cmd [6 :])
135+ elif cmd .startswith ("input" ):
136+ copy = dialogs .input_alert (cmd [6 :])
137+ elif cmd == "copy" :
138+ print (copy )
139+ elif cmd == "others" :
140+
141+ print ("呜呜呜要期中了下载一下吧" )
142+ else :
143+ dialogs .alert (f"'{ cmd } ' 不是内部或外部命令,也不是可运行的程序" )
144+
0 commit comments