无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

NewyearDOS(仿系統(tǒng))

2023-08-11 09:47 作者:新的一year  | 我要投稿

用python做了一個(gè)仿系統(tǒng),歡迎使用,以下是源碼:

import os

print ("歡迎,版本號(hào):0.017")


class NewyearDOS:

? ? def __init__(self):

? ? ? ? self.current_dir = os.getcwd()


? ? def run(self):

? ? ? ? while True:

? ? ? ? ? ? command = input(f"{self.current_dir}> ")

? ? ? ? ? ? self.execute_command(command)


? ? def execute_command(self, command):

? ? ? ? command_parts = command.split()


? ? ? ? if command_parts:

? ? ? ? ? ? cmd = command_parts[0].lower()

? ? ? ? ? ? args = command_parts[1:]


? ? ? ? ? ? if cmd == "cd":

? ? ? ? ? ? ? ? self.change_directory(args)

? ? ? ? ? ? elif cmd == "dir":

? ? ? ? ? ? ? ? self.list_directory()

? ? ? ? ? ? elif cmd == "mkdir":

? ? ? ? ? ? ? ? self.create_directory(args)

? ? ? ? ? ? elif cmd == "rmdir":

? ? ? ? ? ? ? ? self.remove_directory(args)

? ? ? ? ? ? elif cmd == "exit":

? ? ? ? ? ? ? ? exit()

? ? ? ? ? ? elif cmd == "help":

? ? ? ? ? ? ? ? self.show_help()

? ? ? ? ? ? else:

? ? ? ? ? ? ? ? print("無(wú)效的命令")


? ? def change_directory(self, args):

? ? ? ? if args:

? ? ? ? ? ? new_dir = os.path.join(self.current_dir, args[0])

? ? ? ? ? ? if os.path.isdir(new_dir):

? ? ? ? ? ? ? ? self.current_dir = new_dir

? ? ? ? ? ? else:

? ? ? ? ? ? ? ? print("目錄不存在")

? ? ? ? else:

? ? ? ? ? ? print("缺少目錄名")


? ? def list_directory(self):

? ? ? ? files = os.listdir(self.current_dir)

? ? ? ? for file in files:

? ? ? ? ? ? file_path = os.path.join(self.current_dir, file)

? ? ? ? ? ? if os.path.isdir(file_path):

? ? ? ? ? ? ? ? print(f"<DIR>\t{file}")

? ? ? ? ? ? else:

? ? ? ? ? ? ? ? print(f"\t{file}")


? ? def create_directory(self, args):

? ? ? ? if args:

? ? ? ? ? ? new_dir = os.path.join(self.current_dir, args[0])

? ? ? ? ? ? try:

? ? ? ? ? ? ? ? os.mkdir(new_dir)

? ? ? ? ? ? ? ? print(f"目錄 '{args[0]}' 創(chuàng)建成功")

? ? ? ? ? ? except:

? ? ? ? ? ? ? ? print("無(wú)法創(chuàng)建目錄")

? ? ? ? else:

? ? ? ? ? ? print("缺少目錄名")


? ? def remove_directory(self, args):

? ? ? ? if args:

? ? ? ? ? ? dir_path = os.path.join(self.current_dir, args[0])

? ? ? ? ? ? if os.path.isdir(dir_path):

? ? ? ? ? ? ? ? try:

? ? ? ? ? ? ? ? ? ? os.rmdir(dir_path)

? ? ? ? ? ? ? ? ? ? print(f"目錄 '{args[0]}' 刪除成功")

? ? ? ? ? ? ? ? except:

? ? ? ? ? ? ? ? ? ? print("無(wú)法刪除目錄")

? ? ? ? ? ? else:

? ? ? ? ? ? ? ? print("目錄不存在")

? ? ? ? else:

? ? ? ? ? ? print("缺少目錄名")


? ? def show_help(self):

? ? ? ? print("可用命令:")

? ? ? ? print("cd <目錄> - 切換當(dāng)前目錄")

? ? ? ? print("dir - 列出文件和目錄")

? ? ? ? print("mkdir <目錄> - 創(chuàng)建新目錄")

? ? ? ? print("rmdir <目錄> - 刪除目錄")

? ? ? ? print("exit - 退出程序")

? ? ? ? print("help - 顯示可用命令及其描述")



dos = NewyearDOS()

dos.run()

看完了點(diǎn)個(gè)贊吧!?。。。。。。。。。。?/p>


NewyearDOS(仿系統(tǒng))的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
神池县| 彭山县| 屏南县| 文水县| 都兰县| 古田县| 桐城市| 绥棱县| 陈巴尔虎旗| 庐江县| 松江区| 汤原县| 娄烦县| 无极县| 玛曲县| 白水县| 确山县| 富裕县| 托克逊县| 泽普县| 乐山市| 长沙县| 太仓市| 哈尔滨市| 天气| 宜良县| 定陶县| 和龙市| 藁城市| 陆丰市| 库伦旗| 华蓥市| 朔州市| 辰溪县| 高邑县| 大同市| 苍梧县| 读书| 高安市| 榆中县| 鞍山市|