国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(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ó)家法律
天门市| 贡山| 永德县| 桑植县| 玛曲县| 农安县| 郸城县| 宝鸡市| 敦煌市| 湾仔区| 高邑县| 肃南| 民县| 上高县| 平安县| 庄浪县| 三江| 安西县| 依安县| 汤原县| 土默特右旗| 息烽县| 正安县| 泉州市| 长武县| 台江县| 咸宁市| 清镇市| 即墨市| 博乐市| 德格县| 孟津县| 涡阳县| 德保县| 迭部县| 太保市| 丰都县| 泰顺县| 宾川县| 滁州市| 岚皋县|