python下终端彩色print模拟黑客帝国进入电脑界面-爱心版

【python下终端彩色print模拟黑客帝国进入电脑界面-爱心版】1.图
python下终端彩色print模拟黑客帝国进入电脑界面-爱心版文章插图
2.模拟彩图
python下终端彩色print模拟黑客帝国进入电脑界面-爱心版文章插图
3.代码:
import random, time, osimport colorama#终端彩色设置 , 第1步:导出模块#终端彩色设置 , 第2步:定义colorama.init(autoreset = False)RED = colorama.Fore.RED + colorama.Style.BRIGHTCYAN = colorama.Fore.CYAN + colorama.Style.BRIGHTGREEN = colorama.Fore.GREEN + colorama.Style.BRIGHTYELLOW = colorama.Fore.YELLOW + colorama.Style.BRIGHTMAGENTA = colorama.Fore.MAGENTA + colorama.Style.BRIGHT# 清屏(跨平台的)def clear_screen():if os.sep == '/':os.system('clear')else:os.system('cls')# 模拟延时效果# 终端彩色设置 , 第3步:在print的前面加颜色字母:如RED+#注意如果第一个print设置了特定的颜色后 , 之后的紧跟的print的颜色就是紧随ta的颜色 , 如果单独设置需要注明第3步def delay_waiting(content, frequency):print(RED+'%s' % content, end='', flush=True)for x in range(1, frequency):time.sleep(1)print(GREEN+'.',end='', flush=True)time.sleep(1)print(GREEN+' OK.Succeeded!')# 模拟登陆锡安主机def login_haike():clear_screen()#delay_waiting('Warning!!Warning!!\nThe System is being compromised!!!!\nIt is connecting to Haike Host now , please wait!!', 10) #10个点(.)或者10秒print(RED+'△ ! '*10)delay_waiting('Warning!!Warning!!!', 4)delay_waiting('The System is being compromised!!!!', 4)delay_waiting('It is connecting to Haike Host now , please wait!!!!!', 4)time.sleep(0.5)print(MAGENTA+'enter username: Robot')#粉红色=MAGENTAtime.sleep(0.2)print(MAGENTA+'enter password: ******')time.sleep(0.2)delay_waiting(GREEN+'logging in', 4)#3个点(.)或者3秒time.sleep(0.7)clear_screen()print('Hello, Dear Robot! \nYou are good haike! So cool!! I am failure!')time.sleep(1)#login_haike()# 清屏clear_screen()# 创建一个包含了a-z,A-Z,0-9的字符集charts = [*[chr(x) for x in range(65, 123) if x not in range(91, 97)], *map(str, range(10))]# 死循环i=0while i<500:#设置i , 定义500个charts , 否则进入死循环# 每次打印延时0.009秒time.sleep(0.009)print(*random.choices(charts, k=79))i+=1clear_screen()print('欢迎进入黑客帝国!!!!!')print('*'*100)print(MAGENTA+'★'*100)print(GREEN+'*'*100)# 打印菱形s = '*'rows=10#定义rows=10比较好for i in range(1, rows + 1, 2):print((s * i).center(rows))for i in reversed(range(1, rows - 1, 2)):print((s * i).center(rows))time.sleep(0.5)sentence = "Dear, I love you forever!"for char in sentence.split():allChar = []for y in range(12, -12, -1):lst = []lst_con = ''for x in range(-30, 30):formula = ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3if formula <= 0:lst_con += char[(x) % len(char)]else:lst_con += ' 'lst.append(lst_con)allChar += lstprint('\n'.join(allChar))time.sleep(0.5)4.纯属娱乐和学习 , 特效而已 。