大家好,给大家分享一下基于arcgis的python编程秘笈(第2版),很多人还不知道这一点。下面详细解释一下。现在让我们来看看!
前言
今天,我们来做两个可以装逼的代码python可以做一款软件吗。
一、黑客帝国
做这个需要有pygame库。
首先导入库
import random
import pygame
代码部分:
import random
import pygame
PANEL_width = 600
PANEL_highly = 500
FONT_PX = 15
()
winSur = pygame.display.set_mode((PANEL_width, PANEL_highly))
font = .SysFont("", 25)
bg_suface = pygame.Surface((PANEL_width, PANEL_highly), flags=pygame.SRCALPHA)
pygame.Surface.convert(bg_suface)
(pygame.Color(0, 0, 0, 28))
((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 ():
if == :
exit()
elif == pygame.KEYDOWN:
chang = .get_pressed()
if(chang[32]):
exit()
.delay(30)
(bg_suface, (0, 0))
for i in range(len(drops)):
text = random.choice(texts)
(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
()
二、病毒弹窗
导入库:
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 = ()
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.呵呵00000000001)
threads[i].start()
text='病毒' 这里是可以改的。
原文地址1:https://blog.csdn.net/m0_69824302/article/details/135560399
参考资料:python中用turtle画一个圆形 https://blog.csdn.net/SXIAOYAN_/article/details/140061099