文章目录
前言
今天,我们来做两个可以装逼的代码。
一、黑客帝国
做这个需要有pygame库。
首先导入库
import randomimport pygame
代码部分:
import randomimport pygamePANEL_width = 600PANEL_highly = 500FONT_PX = 15pygame.init()winSur = pygame.display.set_mode((PANEL_width, PANEL_highly))font = pygame.font.SysFont("123.ttf", 25)bg_suface = pygame.Surface((PANEL_width, PANEL_highly), flags=pygame.SRCALPHA)pygame.Surface.convert(bg_suface)bg_suface.fill(pygame.Color(0, 0, 0, 28))winSur.fill((0, 0, 0))letter = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm']texts = [ font.render(str(letter[i]), True, (0, 255, 0)) for i in range(26)]column = int(PANEL_width / FONT_PX)drops = [0 for i in range(column)]while True: for event in pygame.event.get(): if event.type == pygame.QUIT: exit() elif event.type == pygame.KEYDOWN: chang = pygame.key.get_pressed() if(chang[32]): exit() pygame.time.delay(30) winSur.blit(bg_suface, (0, 0)) for i in range(len(drops)): text = random.choice(texts) winSur.blit(text, (i * FONT_PX, drops[i] * FONT_PX)) drops[i] += 1 if drops[i] * 10 > PANEL_highly or random.random() > 0.95: drops[i] = 0 pygame.display.flip()
二、病毒弹窗
导入库:
import tkinter as tkimport randomimport threadingimport time
代码:
import tkinter as tkimport randomimport threadingimport timecolor = ['red', '#356F9F']color1 = random.choices(color)def dow(): window = tk.Tk() width = window.winfo_screenwidth() height = window.winfo_screenheight() a = random.randrange(0, width) b = random.randrange(0, height) window.title('Python') window.geometry("200x200" + "+" + str(a) + "+" + str(b)) tk.Label(window, text='病毒', bg=color1, font=('楷体', 17), width=15, height=10 ).pack() window.mainloop()threads = []for i in range(1400): t = threading.Thread(target=dow) threads.append(t) time.sleep(0.0000000000000000000001) threads[i].start()
text='病毒'
这里是可以改的。
总结
今天就到这里,你学会了吗。
鼓起白色的帆;愿你是船,剪开蓝色的波澜。生活正在你的前方微笑,勇敢的走上前去,将彩色的人生拥抱。
来源地址:https://blog.csdn.net/we123aaa4567/article/details/130274093