【python学习小案例】提升兴趣之模拟系统入侵
- 🧛♂️个人主页:杯咖啡
- 💡进步是今天的活动,明天的保证!
- ✨目前正在学习:SSM框架,算法刷题
- 👉本文收录专栏:python小案例
- 🙌牛客网,刷算法过面试的神级网站,用牛客你也牛。 👉免费注册和我一起学习刷题👈
- 🐳希望大家多多支持🥰一起进步呀!
- 😎The man who fears losing has already lost.
怕输的人已经输了。 - 《权力的游戏》
✨前言
本专栏和大家分享一些python学习中的一些小案例。
案例很小却很有趣味,趣味才是最好的老师。
一起陪我看看吧!
@[TOC]
模拟系统入侵
这个小例子很简单,当然肯定不是真的系统入侵哦!!!本案例只适合刚接触python的小白增加兴趣哦!!!
只用到了time和turtle两个库,运行结果为显示入侵进度条,入侵完成屏幕随机弹出弹窗。
运行结果展示



实现代码
import time
import turtle as t
s=50
print("入侵开始".center(60,'-'))
start=time.perf_counter()
for i in range(51):
a='*'*i
b='.'*(s-i)
c=(i/s)*100
end=time.perf_counter()
d=end-start
print("\r{2:^3.0f}%[{0}->{1}]{3:.2f}s".format(a,b,c,d),end="")
time.sleep(0.3)
print("")
print("入侵完成".center(60,'-'))
for x in range(9999):
t.bgcolor("red")
t.setup(150,110,50)
t.setup(400,50,250,300)
t.setup(300,80,100,400)
t.setup(450,100,30)
t.setup(200,2,3,60)
t.setup(25,3,65,560)
t.setup(150,110,50)
t.setup(400,50,600,300)
t.setup(300,80,459,400)
t.setup(450,100,3400)
t.setup(200,2,67,455)
t.setup(50,3,876,321)
t.setup(1000,600,31)
t.setup(1200,600,321)
t.setup(1300,60,321)
t.setup(125,600,321)
t.setup(1100,60,321)
t.setup(1456,600,31)
t.setup(1567,600,321)
t.setup(124,600,321)
t.setup(136,60,321)
t.setup(1567,600,321)
t.setup(1678,600,21)
t.setup(800,800,456)
t.setup(700,800,600,600)
time.sleep(3600000)
✨总结
本案例主要核心就是手工实现了一个进度条的展示,并且在最后附加了形似入侵的感觉。
喜欢的小伙伴可以自行测试一下哦,有惊喜!!!

