自己开发一个“操作系统”,小白也会!(基于Python)

编程入门 行业动态 更新时间:2024-10-26 20:28:42

自己开发一个“操作系统”,小白<a href=https://www.elefans.com/category/jswz/34/1770579.html style=也会!(基于Python)"/>

自己开发一个“操作系统”,小白也会!(基于Python)

 你想要一个自己就会做的操作系统吗?

立即教会你!

安排!

Python得有,用来编写“操作系统”用 下载地址:欢迎来到 Python

微软的Visual Code也可以

下载好之后,在任意位置新建文本文档,然后重命名,把txt变成py

右键用编程工具打开,一定要改打开方式,不然只有一个一闪而过的cmd窗口

好了,开始编程!

import time as tm
import getpass
import datetime
import calendar
import os

以上这些是引入module

没有这些会报错

print("BBC OS (R) Core Open Source System 1.2")
print("Avaliable update! Visit bbc to update")

以上这些是“开机”自动弹出的话

你们可以改,我这里拿BBC OS做例子

count = 0
stpasswd = "114514"

以上设置密码为“114514”

你们可以改

while count < 3:user = input("Login: ")if user == "root":while count < 3:passwd = getpass.getpass("Password: ")if passwd == stpasswd:

以上是登录部分

                tm.sleep(1.5)while count < 3:cmd = input("~ $ ")if cmd == "ls":print("Downloads  Documents  Music  Pictures")elif cmd == "version":print("BBC OS (R) Core Open Source System 1.2 ")elif cmd == "coverter":print("File Covert\nCovert .lpap/.lpcu/.bbc to .umm")input("Input file's path:\n")print("Coverting [____________________] 0%")tm.sleep(0.3)print("Coverting [######______________] 30%")tm.sleep(0.3)print("Coverting [############________] 60%")tm.sleep(0.3)print("Coverting [################____] 80%")tm.sleep(0.3)print("Coverting [####################] 100%")tm.sleep(0.09)

以上是进度条

                        print("Covert Complete.")elif cmd == "time":now = datetime.datetime.now()other_StyleTime = now.strftime("%Y-%m-%d %H:%M:%S")print(other_StyleTime)

以上是时间功能

                    elif cmd == "passwd":stpasswd = input("Input new password: ")

以上是重置密码功能

                    elif cmd == "calendar":yy = int(input("Year: "))mm = int(input("Month: "))print(calendar.month(yy, mm))

以上是日历功能

                    elif cmd == "help":print("ls          View the path")print("version     Show the system's version")print("coverter    A tool to covert .lpap/.lpcu/.bbc to .umm")print("time        Show the time and date")print("calendar    Show a calendar")print("calc        A simple calculator")print("clear       Clean the screen")print("passwd      Change your password")print("exit        Log out")

以上是help帮助面板

                    elif cmd == "calc":try:formula = input("Enter the formula to be calculated:\n")print(formula + "=", eval(formula))except Exception as e:print("Input error.")

以上是计算器模块

                    elif cmd == "clear":i = os.system("cls")

以上是清屏模块

                    elif cmd == "exit":break

以上是退出模块

                    else:print("Unknown command.")

以上是未知代码提示

            else:print("Error password! Please retry")

以上是密码错误提示

    else:print("Invalid user! Please retry")

以上是用户名错误提示

编写完成,收工!

转载请注明出处,谢谢

更多推荐

自己开发一个“操作系统”,小白也会!(基于Python)

本文发布于:2024-02-27 04:07:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1705114.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:也会   操作系统   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!