猫史档案馆


我需要复制粘贴

我需要复制粘贴

Lv.1

整个世界美好的时光,就像一串串代码,只要知道它的形成,就能制作美丽的程序

获赞:97收藏:12浏览:2624作品收藏:69

签名:我现在正在做好玩,有趣的游戏,但是在这之前,网络不要崩溃哦

回复帖子评论
上一页2 页 / 共 2下一页

【Python作品分享】爬虫程序升级版 中回复

这只能获取到里面的文本

使用解析模块:

lxml

解析文本:

response.get(url)

from lxml import etree

ht ml=etree.Ht mL(response.text)

text=html.xpath("")

xpath可以按F12打开调试工具

在要解析的部分点击右键选择copy选择xopy xpath

2021-07-14T12:55:49 点赞:0

pygame做个贪吃蛇(下期学习下载PYCHARM) 中回复

from pygame import *
from sys import *
from random import *
init()
font.init()
screen=display.set_mode((600,400))
screen.fill((20,139,69))
display.set_caption("贪吃蛇")
c = []
x=0
y=0
right=True
left=False
up=False
down=False
n=-3
l=True
s=0
while True:
    draw.rect(screen,(0,139,69),(0,0,100,100))
    screen.blit(font.SysFont("simhei",100).render(str(s),True,(0,0,0)),(0,0))
    for a in event.get():
        if a.type==QUIT:
            quit()
            exit()
        if a.type==KEYDOWN:
            if a.key==K_RIGHT and y>0 and y<400:
                right=True
                left=False
                up=False
                down=False
            if a.key==K_LEFT and y>0 and y<400:
                right=False
                left=True
                up=False
                down=False
            if a.key==K_UP and x>0 and x<600:
                right=False
                left=False
                up=True
                down=False
            if a.key==K_DOWN and x>0 and x<600 :
                right=False
                left=False
                up=False
                down=True
    if right:
        x+=40
    if down:
        y+=40
    if up:
        y-=40
    if left:
        x-=40
    if y>400:
        y=0
    if y<0:
        y=400
    if x<0:
        x=600
    if x>600:
        x=0
    c.append((x,y))
    draw.rect(screen,(0,255,255),(x,y,40,40))
    if l:
        p=(randint(1,9)*40,randint(1,9)*40)
        draw.rect(screen,(255,246,143),(p[0],p[1],40,40))
        l=False
    if x==p[0] and y==p[1]:
        s+=1
        draw.rect(screen,(0,255,255),(x,y,40,40))
        c.append((x,y))
        l=True
    time.Clock().tick(6)
    if n>-1:
        draw.rect(screen,(0,139,69),(c[n][0],c[n][1],40,40))
    n+=1
    display.flip()

2021-07-14T12:58:03 点赞:0

pygame做个贪吃蛇(下期学习下载PYCHARM) 中回复

70行代码解决问题

2021-07-14T12:58:30 点赞:0

pygame做个贪吃蛇(下期学习下载PYCHARM) 中回复

安装pygame跟codemao库有什么关系

2021-07-14T12:58:58 点赞:0

pygame做个贪吃蛇(下期学习下载PYCHARM) 中回复

不要使用pycharm建议visualstudio2017

2021-07-14T13:00:14 点赞:0

【岛3萌新代码教程!】从0开始手把手教你写代码 中回复

js脚本

2021-08-09T21:34:25 点赞:0