python/pygame 挑战魂斗罗 笔记(三)

2024-04-18 13:28

本文主要是介绍python/pygame 挑战魂斗罗 笔记(三),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

感觉最难的部分已经解决了,下面开始发射子弹。

一、建立ContraBullet.py文件,Bullit类:

1、设定子弹速度

Config.py中设定子弹移动速度为常量Constant.BULLET_SPEED = 8。

2、载入子弹图片:

图片也是6张,子弹发出后逐渐变大(这是为什么呢)?同样建立bullet_list列表和bullet_number索引。载入图片后获取rect属性再按照人物放大比例放大,加到子弹列表中。

3、子弹图片索引

设置一个计数器变量counter,随着循环增加到30,也就是1/2个FPS,就让子弹图片索引增加1,改变子弹图片样式。

import os.pathimport pygamefrom Config import Constantclass Bullet(pygame.sprite.Sprite):def __init__(self, x, y):pygame.sprite.Sprite.__init__(self)self.bullet_list = []self.bullet_number = 0for i in range(6):image = pygame.image.load(os.path.join('image', 'bullet', 'bullet' + str(i + 1) + '.png'))rect = image.get_rect()image = pygame.transform.scale(image, (rect.width * Constant.PLAYER_SCALE, rect.height * Constant.PLAYER_SCALE))self.bullet_list.append(image)self.image = self.bullet_list[self.bullet_number]self.rect = self.image.get_rect()self.rect.centerx = xself.rect.centery = yself.speed_x = 0self.speed_y = 0self.counter = 0def update(self):if self.counter >= 30:self.bullet_number += 1if self.bullet_number > 5:self.bullet_number = 0else:self.counter += 1self.image = self.bullet_list[self.bullet_number]self.rect.x += self.speed_xself.rect.y += self.speed_y

二、Bill类增加按键判定以及shoot发射方法:

1、设定k键为发射子弹以及子弹发射间隔时间、子弹x、y方向移速和不同角度子弹发射位置等变量。
            self.bullet_time = 0self.bullet_speed_x = 0self.bullet_speed_y = 0self.bullet_x = self.rect.rightself.bullet_y = self.rect.y + 11.5 * Constant.PLAYER_SCALE
2、建立shoot发射子弹方法:

主要是理清各种方向、状态下子弹的发射位置和x、y方向的速度。

    def shoot(self):if self.direction == 'right':self.bullet_speed_x = Constant.BULLET_SPEEDself.bullet_x = self.rect.rightelif self.direction == 'left':self.bullet_speed_x = -Constant.BULLET_SPEEDself.bullet_x = self.rect.leftif self.image_type == 'stand':self.bullet_y = self.rect.y + 11.5 * Constant.PLAYER_SCALEself.bullet_speed_y = 0elif self.image_type == 'down':self.bullet_y = self.rect.y + 24 * Constant.PLAYER_SCALEself.bullet_speed_y = 0elif self.image_type == 'up':self.bullet_y = self.rect.yself.bullet_speed_x = 0self.bullet_speed_y = -Constant.BULLET_SPEEDelif self.image_type == 'oblique_down':self.bullet_y = self.rect.y + 20.5 * Constant.PLAYER_SCALEself.bullet_speed_y = Constant.BULLET_SPEEDelif self.image_type == 'oblique_up':self.bullet_y = self.rect.yself.bullet_speed_y = -Constant.BULLET_SPEEDif self.bullet_time >= 30:bill_bullet = ContraBullet.Bullet(self.bullet_x, self.bullet_y)bill_bullet.speed_x = self.bullet_speed_xbill_bullet.speed_y = self.bullet_speed_yVariable.all_sprites.add(bill_bullet)self.bullet_time = 0else:self.bullet_time += 1

子弹发射成功! 

三、添加敌人:

1、敌人图片载入

敌人就简单一点吧,只选择了一个图片形象的,PS处理完,一共7张图片,6个行走运动的,1个射击状态的,这里让敌人从游戏窗口外面开始落下来,坠落状态的图片就省去了。

设定一个敌人图片列表,同样需要载入图片并按照PLAYER_SCALE比例放大。

再设定一些变量,来控制敌人的产生时间间隔以及发射子弹间隔等。

import os.path
import randomimport pygamefrom Config import Constant, Variableclass Enemy(pygame.sprite.Sprite):def __init__(self):pygame.sprite.Sprite.__init__(self)self.enemy_list = []for i in range(7):image = pygame.image.load(os.path.join('image', 'enemy', 'enemy' + str(i + 1) + '.png'))rect = image.get_rect()image = pygame.transform.scale(image, (rect.width * Constant.PLAYER_SCALE, rect.height * Constant.PLAYER_SCALE))image = pygame.transform.flip(image, True, False)self.enemy_list.append(image)self.order = 0self.shooting = Falseif self.shooting:self.image = self.enemy_list[6]else:self.image = self.enemy_list[self.order]self.rect = self.image.get_rect()self.rect.x = random.randrange(Constant.WIDTH, Constant.WIDTH * 5)self.rect.y = 100self.counter = 0self.speed = 2self.floor = 0self.last_time = 0self.now_time = 0
2、敌人的产生方法

定义一个敌人的组,用来判定碰撞及控制敌人数量。

0-100之间取一个随机数,等与50时产生一个敌人,分别加入敌人组和所有精灵组。

def new_enemy():if Variable.step == 2 and len(Variable.enemy_sprites) <= 3:i = random.randint(0, 100)if i == 50:enemy = Enemy()Variable.all_sprites.add(enemy)Variable.enemy_sprites.add(enemy)
3、移动及射击

先写个索引循环方法,控制order,每完成一次移动图片,计数器counter+1,到5时射击一次。也就是6张移动图片轮回5次就射击一次。

    def order_loop(self):self.now_time = pygame.time.get_ticks()if self.now_time - self.last_time >= 150:self.order += 1if self.order > 6:self.counter += 1self.order = 0if self.counter >= 5:self.shooting = Trueself.last_time = self.now_time

 再定义一个射击方法,子弹的位置和移动速度

    def shoot(self):enemy_bullet = ContraBullet.Bullet(self.rect.left, self.rect.y + 7.5 * Constant.PLAYER_SCALE)enemy_bullet.speed_x = -10Variable.all_sprites.add(enemy_bullet)self.shooting = Falseself.counter = 0

 更新update,实现移动、图片改变及射击。同样也是让敌人一直处于下落状态,碰到地面碰撞体就停止下落,并向左移动。这里写的比较简单,没有考虑敌人的跳跃问题。

    def update(self):if self.shooting:self.image = self.enemy_list[6]else:self.image = self.enemy_list[self.order]self.rect.y += Constant.GRAVITY * 10self.order_loop()if self.shooting:self.shoot()collider_ground = pygame.sprite.groupcollide(Variable.enemy_sprites, Variable.collider, False, False)for e, l in collider_ground.items():self.floor = l[0].rect.tope.rect.bottom = self.floore.rect.x -= self.speed

四、全部文件:

剩下的就是各种碰撞检测和关头了,这里就不再写啦。把所有文件都完整贴一遍。

1、Contra.py主循环文件

感觉都挺长时间没改动这个文件了,就增加了一个ContraEnemy.new_enemy()。

# Contra.py
import sys
import pygameimport ContraBill
import ContraMap
import ContraEnemy
from Config import Constant, Variabledef control():for event in pygame.event.get():if event.type == pygame.QUIT:Variable.game_start = Falseif event.type == pygame.KEYDOWN:if event.key == pygame.K_RETURN:Variable.step = 1class Main:def __init__(self):pygame.init()self.game_window = pygame.display.set_mode((Constant.WIDTH, Constant.HEIGHT))self.clock = pygame.time.Clock()def game_loop(self):while Variable.game_start:control()if Variable.stage == 1:ContraMap.new_stage()ContraBill.new_player()ContraEnemy.new_enemy()if Variable.stage == 2:passif Variable.stage == 3:passVariable.all_sprites.draw(self.game_window)Variable.all_sprites.update()self.clock.tick(Constant.FPS)pygame.display.set_caption(f'魂斗罗  1.0    {self.clock.get_fps():.2f}')pygame.display.update()pygame.quit()sys.exit()if __name__ == '__main__':main = Main()main.game_loop()
2、ContraMap.py第一关背景地图及地面碰撞体文件

别的关的背景地图也是按照这个方式,再单独测算每个台阶的位置和长度,一条条的把地面碰撞体给绘制出来就可以了。

# ContraMap.py
import os
import pygamefrom Config import Constant, Variableclass StageMap(pygame.sprite.Sprite):def __init__(self, order):pygame.sprite.Sprite.__init__(self)self.image_list = []self.order = orderfor i in range(1, 9):image = pygame.image.load(os.path.join('image', 'map', 'stage' + str(i) + '.png'))rect = image.get_rect()image = pygame.transform.scale(image, (rect.width * Constant.MAP_SCALE, rect.height * Constant.MAP_SCALE))self.image_list.append(image)self.image = self.image_list[self.order]self.rect = self.image.get_rect()self.rect.x = 0self.rect.y = 0self.speed = 0def update(self):if self.order == 2:print('纵向地图')else:if Variable.step == 0 and self.rect.x >= -Constant.WIDTH:self.rect.x -= 10if Variable.step == 1 and self.rect.x > -Constant.WIDTH * 2:self.rect.x -= 10if self.rect.x == -Constant.WIDTH * 2:Variable.step = 2Variable.all_sprites.add(Variable.collider)def new_stage():if Variable.map_switch:stage_map = StageMap(Variable.stage - 1)Variable.all_sprites.add(stage_map)Variable.map_storage.add(stage_map)Variable.map_switch = Falseclass CollideGround(pygame.sprite.Sprite):def __init__(self, length, x, y):pygame.sprite.Sprite.__init__(self)self.image = pygame.Surface((length * Constant.MAP_SCALE, 3))self.image.fill((255, 0, 0))self.rect = self.image.get_rect()self.rect.x = x * Constant.MAP_SCALE - Constant.WIDTH * 2self.rect.y = y * Constant.MAP_SCALEVariable.collider83.add(CollideGround(511, 2176, 83),CollideGround(161, 2847, 83),CollideGround(64, 3296, 83)
)Variable.collider115.add(CollideGround(736, 832, 115),CollideGround(128, 1568, 115),CollideGround(160, 1695, 115),CollideGround(128, 1856, 115),CollideGround(256, 1984, 115),CollideGround(224, 2656, 115),CollideGround(65, 3040, 115),CollideGround(64, 3264, 115),CollideGround(64, 3392, 115),CollideGround(128, 3808, 115)
)Variable.collider146.add(CollideGround(97, 959, 146),CollideGround(66, 1215, 146),CollideGround(225, 2400, 146),CollideGround(96, 2976, 146),CollideGround(64, 3136, 146),CollideGround(160, 3424, 146),CollideGround(64, 3744, 146),CollideGround(32, 3936, 146)
)Variable.collider163.add(CollideGround(95, 1440, 163),CollideGround(64, 2304, 163),CollideGround(32, 2912, 163),CollideGround(32, 2328, 163),CollideGround(32, 3328, 163),CollideGround(97, 3840, 163)
)Variable.collider178.add(CollideGround(32, 1055, 178),CollideGround(32, 1151, 178),CollideGround(65, 2720, 178),CollideGround(64, 2816, 178),CollideGround(96, 3168, 178),CollideGround(63, 3648, 178),CollideGround(32, 3969, 178)
)Variable.collider211.add(CollideGround(63, 1088, 211),CollideGround(63, 1407, 211),CollideGround(97, 2208, 211),CollideGround(192, 2528, 211),CollideGround(33, 3135, 211),CollideGround(33, 3295, 211),CollideGround(97, 3520, 211),CollideGround(242, 3807, 211)
)Variable.collider.add(Variable.collider83, Variable.collider115, Variable.collider146, Variable.collider163,Variable.collider178, Variable.collider211, Variable.collider231)
3、ContraBill.py主角玩家文件

主角Bill向下跳跃,后来想了想,是不是可以考虑写一个矮点的碰撞体紧随Bill的脚下,然后由这个碰撞体来检测是否和地面碰撞体碰撞,这样就不用等Bill的top超过地面碰撞体就可以把它加回来了。而且在往上跳时,也不会因为两层地面距离太近直接跳到上面层了,感觉体验感应该会好些。

# ContraBill.py
import os
import pygameimport ContraBulletfrom Config import Constant, Variableclass Bill(pygame.sprite.Sprite):def __init__(self):pygame.sprite.Sprite.__init__(self)self.image_dict = {'be_hit': [],'down': [],'jump': [],'oblique_down': [],'oblique_up': [],'run': [],'shoot': [],'stand': [],'up': []}for i in range(6):for key in self.image_dict:image = pygame.image.load(os.path.join('image', 'bill', str(key), str(key) + str(i + 1) + '.png'))rect = image.get_rect()image_scale = pygame.transform.scale(image, (rect.width * Constant.PLAYER_SCALE, rect.height * Constant.PLAYER_SCALE))self.image_dict[key].append(image_scale)self.image_order = 0self.image_type = 'stand'self.image = self.image_dict[self.image_type][self.image_order]self.rect = self.image.get_rect()self.rect.x = 100self.rect.y = 100self.direction = 'right'self.now_time = 0self.last_time = 0self.falling = Trueself.jumping = Falseself.moving = Falseself.floor = 0self.bullet_time = 0self.bullet_speed_x = 0self.bullet_speed_y = 0self.bullet_x = self.rect.rightself.bullet_y = self.rect.y + 11.5 * Constant.PLAYER_SCALEdef update(self):self.image = self.image_dict[self.image_type][self.image_order]if self.direction == 'left':self.image = pygame.transform.flip(self.image, True, False)if self.rect.top >= self.floor:for i in Variable.sprite_storage:Variable.collider.add(i)Variable.sprite_storage.remove(i)key_pressed = pygame.key.get_pressed()if self.falling:self.fall()if self.jumping:self.jump()if self.moving:self.move()self.order_loop()collider_ground = pygame.sprite.groupcollide(Variable.player_sprites, Variable.collider, False, False)for p, l in collider_ground.items():self.floor = l[0].rect.topp.rect.bottom = self.floorif key_pressed[pygame.K_k]:self.shoot()if key_pressed[pygame.K_d]:self.direction = 'right'self.moving = Trueif key_pressed[pygame.K_w]:self.image_type = 'oblique_up'elif key_pressed[pygame.K_s]:self.image_type = 'oblique_down'elif key_pressed[pygame.K_j]:self.image_type = 'jump'self.jumping = Trueself.falling = Falseelse:self.image_type = 'run'elif key_pressed[pygame.K_a]:self.direction = 'left'self.moving = Trueif key_pressed[pygame.K_w]:self.image_type = 'oblique_up'elif key_pressed[pygame.K_s]:self.image_type = 'oblique_down'elif key_pressed[pygame.K_j]:self.image_type = 'jump'self.jumping = Trueself.falling = Falseelse:self.image_type = 'run'elif key_pressed[pygame.K_w]:self.image_type = 'up'self.moving = Falseelif key_pressed[pygame.K_s]:self.image_type = 'down'self.moving = Falseelse:self.image_type = 'stand'self.moving = Falseif key_pressed[pygame.K_s] and key_pressed[pygame.K_j]:self.image_type = 'oblique_down'Variable.collider.remove(l[0])Variable.sprite_storage.add(l[0])def shoot(self):if self.direction == 'right':self.bullet_speed_x = Constant.BULLET_SPEEDself.bullet_x = self.rect.rightelif self.direction == 'left':self.bullet_speed_x = -Constant.BULLET_SPEEDself.bullet_x = self.rect.leftif self.image_type == 'stand':self.bullet_y = self.rect.y + 11.5 * Constant.PLAYER_SCALEself.bullet_speed_y = 0elif self.image_type == 'down':self.bullet_y = self.rect.y + 24 * Constant.PLAYER_SCALEself.bullet_speed_y = 0elif self.image_type == 'up':self.bullet_y = self.rect.yself.bullet_speed_x = 0self.bullet_speed_y = -Constant.BULLET_SPEEDelif self.image_type == 'oblique_down':self.bullet_y = self.rect.y + 20.5 * Constant.PLAYER_SCALEself.bullet_speed_y = Constant.BULLET_SPEEDelif self.image_type == 'oblique_up':self.bullet_y = self.rect.yself.bullet_speed_y = -Constant.BULLET_SPEEDif self.bullet_time >= 30:bill_bullet = ContraBullet.Bullet(self.bullet_x, self.bullet_y)bill_bullet.speed_x = self.bullet_speed_xbill_bullet.speed_y = self.bullet_speed_yVariable.all_sprites.add(bill_bullet)self.bullet_time = 0else:self.bullet_time += 1def order_loop(self):self.now_time = pygame.time.get_ticks()if self.now_time - self.last_time >= 100:self.image_order += 1if self.image_order > 5:self.image_order = 0self.last_time = self.now_timedef move(self):if self.direction == 'right' and self.rect.right <= Constant.WIDTH - 80 * Constant.MAP_SCALE:self.rect.x += Constant.SPEED_Xif self.rect.centerx >= Constant.WIDTH / 2:x = self.rect.centerx - Constant.WIDTH / 2for j in Variable.map_storage:if j.rect.right >= Constant.WIDTH:for i in Variable.all_sprites:i.rect.x -= xelif self.direction == 'left' and self.rect.left >= 40 * Constant.MAP_SCALE:self.rect.x -= Constant.SPEED_Xif self.rect.centerx <= Constant.WIDTH / 2:x = Constant.WIDTH / 2 - self.rect.centerxfor j in Variable.map_storage:if j.rect.left <= -Constant.WIDTH * 2:for i in Variable.all_sprites:i.rect.x += xdef jump(self):Constant.SPEED_Y += Constant.GRAVITYself.rect.y += Constant.SPEED_Yif Constant.SPEED_Y == 0:self.jumping = Falseself.falling = TrueConstant.SPEED_Y = -10def fall(self):self.rect.y += Constant.GRAVITY * 10def new_player():if Variable.step == 2 and Variable.player_switch:bill = Bill()Variable.all_sprites.add(bill)Variable.player_sprites.add(bill)Variable.player_switch = False
4、ContraEnemy.py

敌人这里写的太简单了,连出游戏窗口的判定都没写!我记得正常游戏里面还有一些在墙上的炮台啥的,还有随机掉落的各种buff以及关头。

import os.path
import randomimport pygameimport ContraBullet
from Config import Constant, Variableclass Enemy(pygame.sprite.Sprite):def __init__(self):pygame.sprite.Sprite.__init__(self)self.enemy_list = []for i in range(7):image = pygame.image.load(os.path.join('image', 'enemy', 'enemy' + str(i + 1) + '.png'))rect = image.get_rect()image = pygame.transform.scale(image, (rect.width * Constant.PLAYER_SCALE, rect.height * Constant.PLAYER_SCALE))image = pygame.transform.flip(image, True, False)self.enemy_list.append(image)self.order = 0self.shooting = Falseif self.shooting:self.image = self.enemy_list[6]else:self.image = self.enemy_list[self.order]self.rect = self.image.get_rect()self.rect.x = random.randrange(Constant.WIDTH, Constant.WIDTH * 5)self.rect.y = 100self.counter = 0self.speed = 2self.floor = 0self.last_time = 0self.now_time = 0def update(self):if self.shooting:self.image = self.enemy_list[6]else:self.image = self.enemy_list[self.order]self.rect.y += Constant.GRAVITY * 10self.order_loop()if self.shooting:self.shoot()collider_ground = pygame.sprite.groupcollide(Variable.enemy_sprites, Variable.collider, False, False)for e, l in collider_ground.items():self.floor = l[0].rect.tope.rect.bottom = self.floore.rect.x -= self.speeddef order_loop(self):self.now_time = pygame.time.get_ticks()if self.now_time - self.last_time >= 150:self.order += 1if self.order > 6:self.counter += 1self.order = 0if self.counter >= 5:self.shooting = Trueself.last_time = self.now_timedef shoot(self):enemy_bullet = ContraBullet.Bullet(self.rect.left, self.rect.y + 7.5 * Constant.PLAYER_SCALE)enemy_bullet.speed_x = -10Variable.all_sprites.add(enemy_bullet)self.shooting = Falseself.counter = 0def new_enemy():if Variable.step == 2 and len(Variable.enemy_sprites) <= 3:i = random.randint(0, 100)if i == 50:enemy = Enemy()Variable.all_sprites.add(enemy)Variable.enemy_sprites.add(enemy)
5、ContraBullet.py

子弹这里没有区分双方的子弹,同样也没写出游戏窗口后kill。

import os.pathimport pygamefrom Config import Constantclass Bullet(pygame.sprite.Sprite):def __init__(self, x, y):pygame.sprite.Sprite.__init__(self)self.bullet_list = []self.bullet_number = 0for i in range(6):image = pygame.image.load(os.path.join('image', 'bullet', 'bullet' + str(i + 1) + '.png'))rect = image.get_rect()image = pygame.transform.scale(image, (rect.width * Constant.PLAYER_SCALE, rect.height * Constant.PLAYER_SCALE))self.bullet_list.append(image)self.image = self.bullet_list[self.bullet_number]self.rect = self.image.get_rect()self.rect.centerx = xself.rect.centery = yself.speed_x = 0self.speed_y = 0self.counter = 0def update(self):if self.counter >= 30:self.bullet_number += 1if self.bullet_number > 5:self.bullet_number = 0else:self.counter += 1self.image = self.bullet_list[self.bullet_number]self.rect.x += self.speed_xself.rect.y += self.speed_y
6、Config.py

把游戏的全局常量、变量单独写出来,感觉在调用时还是挺方便的。

# Config.py
import pygameclass Constant:WIDTH = 1200HEIGHT = 720FPS = 60MAP_SCALE = 3PLAYER_SCALE = 2.5SPEED_X = 3SPEED_Y = -10GRAVITY = 0.5BULLET_SPEED = 8class Variable:all_sprites = pygame.sprite.Group()player_sprites = pygame.sprite.Group()enemy_sprites = pygame.sprite.Group()collider = pygame.sprite.Group()collider83 = pygame.sprite.Group()collider115 = pygame.sprite.Group()collider146 = pygame.sprite.Group()collider163 = pygame.sprite.Group()collider178 = pygame.sprite.Group()collider211 = pygame.sprite.Group()collider231 = pygame.sprite.Group()sprite_storage = pygame.sprite.Group()map_storage = pygame.sprite.Group()game_start = Truemap_switch = Trueplayer_switch = Trueenemy_counter = 0stage = 1step = 0

这篇关于python/pygame 挑战魂斗罗 笔记(三)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/914910

相关文章

python: 多模块(.py)中全局变量的导入

文章目录 global关键字可变类型和不可变类型数据的内存地址单模块(单个py文件)的全局变量示例总结 多模块(多个py文件)的全局变量from x import x导入全局变量示例 import x导入全局变量示例 总结 global关键字 global 的作用范围是模块(.py)级别: 当你在一个模块(文件)中使用 global 声明变量时,这个变量只在该模块的全局命名空

跨国公司撤出在华研发中心的启示:中国IT产业的挑战与机遇

近日,IBM中国宣布撤出在华的两大研发中心,这一决定在IT行业引发了广泛的讨论和关注。跨国公司在华研发中心的撤出,不仅对众多IT从业者的职业发展带来了直接的冲击,也引发了人们对全球化背景下中国IT产业竞争力和未来发展方向的深思。面对这一突如其来的变化,我们应如何看待跨国公司的决策?中国IT人才又该如何应对?中国IT产业将何去何从?本文将围绕这些问题展开探讨。 跨国公司撤出的背景与

【Python编程】Linux创建虚拟环境并配置与notebook相连接

1.创建 使用 venv 创建虚拟环境。例如,在当前目录下创建一个名为 myenv 的虚拟环境: python3 -m venv myenv 2.激活 激活虚拟环境使其成为当前终端会话的活动环境。运行: source myenv/bin/activate 3.与notebook连接 在虚拟环境中,使用 pip 安装 Jupyter 和 ipykernel: pip instal

【机器学习】高斯过程的基本概念和应用领域以及在python中的实例

引言 高斯过程(Gaussian Process,简称GP)是一种概率模型,用于描述一组随机变量的联合概率分布,其中任何一个有限维度的子集都具有高斯分布 文章目录 引言一、高斯过程1.1 基本定义1.1.1 随机过程1.1.2 高斯分布 1.2 高斯过程的特性1.2.1 联合高斯性1.2.2 均值函数1.2.3 协方差函数(或核函数) 1.3 核函数1.4 高斯过程回归(Gauss

【学习笔记】 陈强-机器学习-Python-Ch15 人工神经网络(1)sklearn

系列文章目录 监督学习:参数方法 【学习笔记】 陈强-机器学习-Python-Ch4 线性回归 【学习笔记】 陈强-机器学习-Python-Ch5 逻辑回归 【课后题练习】 陈强-机器学习-Python-Ch5 逻辑回归(SAheart.csv) 【学习笔记】 陈强-机器学习-Python-Ch6 多项逻辑回归 【学习笔记 及 课后题练习】 陈强-机器学习-Python-Ch7 判别分析 【学

系统架构师考试学习笔记第三篇——架构设计高级知识(20)通信系统架构设计理论与实践

本章知识考点:         第20课时主要学习通信系统架构设计的理论和工作中的实践。根据新版考试大纲,本课时知识点会涉及案例分析题(25分),而在历年考试中,案例题对该部分内容的考查并不多,虽在综合知识选择题目中经常考查,但分值也不高。本课时内容侧重于对知识点的记忆和理解,按照以往的出题规律,通信系统架构设计基础知识点多来源于教材内的基础网络设备、网络架构和教材外最新时事热点技术。本课时知识

BUUCTF靶场[web][极客大挑战 2019]Http、[HCTF 2018]admin

目录   [web][极客大挑战 2019]Http 考点:Referer协议、UA协议、X-Forwarded-For协议 [web][HCTF 2018]admin 考点:弱密码字典爆破 四种方法:   [web][极客大挑战 2019]Http 考点:Referer协议、UA协议、X-Forwarded-For协议 访问环境 老规矩,我们先查看源代码

nudepy,一个有趣的 Python 库!

更多资料获取 📚 个人网站:ipengtao.com 大家好,今天为大家分享一个有趣的 Python 库 - nudepy。 Github地址:https://github.com/hhatto/nude.py 在图像处理和计算机视觉应用中,检测图像中的不适当内容(例如裸露图像)是一个重要的任务。nudepy 是一个基于 Python 的库,专门用于检测图像中的不适当内容。该

pip-tools:打造可重复、可控的 Python 开发环境,解决依赖关系,让代码更稳定

在 Python 开发中,管理依赖关系是一项繁琐且容易出错的任务。手动更新依赖版本、处理冲突、确保一致性等等,都可能让开发者感到头疼。而 pip-tools 为开发者提供了一套稳定可靠的解决方案。 什么是 pip-tools? pip-tools 是一组命令行工具,旨在简化 Python 依赖关系的管理,确保项目环境的稳定性和可重复性。它主要包含两个核心工具:pip-compile 和 pip

HTML提交表单给python

python 代码 from flask import Flask, request, render_template, redirect, url_forapp = Flask(__name__)@app.route('/')def form():# 渲染表单页面return render_template('./index.html')@app.route('/submit_form',