文章目录
- 前言
- 一、黑客帝国
- 二、病毒弹窗
- 总结
前言
今天,我们来做两个可以装逼的代码。
一、黑客帝国
做这个需要有pygame库。
首先导入库
import random
import pygame
代码部分:
import random
import pygame
PANEL_width = 600
PANEL_highly = 500
FONT_PX = 15
pygame.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 tk
import random
import threading
import time
代码:
import tkinter as tk
import random
import threading
import time
color = ['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://www.toymoban.com/news/detail-507724.html
鼓起白色的帆;愿你是船,剪开蓝色的波澜。生活正在你的前方微笑,勇敢的走上前去,将彩色的人生拥抱。文章来源地址https://www.toymoban.com/news/detail-507724.html
到了这里,关于Python装逼代码的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!