上期答案(看看你找对了没)

一:


while True:
    print("我是客走遗剑")
    sleep(5)

sleep没导库!!是time库

from time import *
while True:
    print("我是客走遗剑")
    sleep(5)

二:

for i in range(10)
    print("我是客走遗剑")

for 循环没加冒号!!

for i in range(10):
    print("我是客走遗剑")

三:(最难)

import pygame
import random
SCREENSIZE=(600,600)
BLACK=(0,0,0,13)
pygame.init()
font = pygame.font.SysFont(宋体, 20)
screen = pygame.display.set_mode(SCREENSIZE)
surface = pygame.Surface(SCREENSIZE, flags=pygame.SRCALPHA)
pygame.Surface.convert(surface)
surface.fill(BLACK)
screen.fill(BLACK)
lib=[chr(i) for i in range(48,48+10)] + [chr(i) for i in range(97,97+26)]  
texts = [font.render(l, True, (0, 255, 0)) for l in lib]
cols = list(range(40)) 
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit()
    pygame.time.delay(33)
    screen.blit(surface, (0, 0))
    for i in range(n:=len(cols)):
        text = random.choice(texts)
        screen.blit(text, (i * 15, cols[i] * 15))
        cols[i] = 0 if cols[i] >80 or random.random() > 0.95 else cols[i]+1
    pygame.display.flip()

第6行没加引号!!(宋体那个)应为:

import pygame
import random
SCREENSIZE=(600,600)
BLACK=(0,0,0,13)
pygame.init()
font = pygame.font.SysFont('宋体', 20)
screen = pygame.display.set_mode(SCREENSIZE)
surface = pygame.Surface(SCREENSIZE, flags=pygame.SRCALPHA)
pygame.Surface.convert(surface)
surface.fill(BLACK)
screen.fill(BLACK)
lib=[chr(i) for i in range(48,48+10)] + [chr(i) for i in range(97,97+26)]  
texts = [font.render(l, True, (0, 255, 0)) for l in lib]
cols = list(range(40)) 
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit()
    pygame.time.delay(33)
    screen.blit(surface, (0, 0))
    for i in range(n:=len(cols)):
        text = random.choice(texts)
        screen.blit(text, (i * 15, cols[i] * 15))
        cols[i] = 0 if cols[i] >80 or random.random() > 0.95 else cols[i]+1
    pygame.display.flip()

懂了吗?

下期见,欢迎关注!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值