钢琴块小游戏(附源码)

 代码结构

app.png是游戏运行主界面的图片(可以加载自己喜欢的主界面图片)

 Assets文件夹里面装的是一些需要用到的游戏图片

全部都可以替换为自己喜欢的图片

Fonts里面装的是

 Sounds文件夹里面装的是

 一 . 主程序代码

1.运行这个代码使得游戏开始

2.主界面的图片可以自己下载一些喜欢的图片 修改路径即可

3.报错就是缺少必要文件 有需要的可以联系我 (我把整个代码给你)


# 导入必要的包
import json
import random
import pygame
from threading import Thread

from objects import Tile, Square, Text, Button, Counter

pygame.init()
SCREEN = WIDTH, HEIGHT = 288, 512
TILE_WIDTH = WIDTH // 4
TILE_HEIGHT = 130

info = pygame.display.Info()
width = info.current_w
height = info.current_h

if width >= height:
	win = pygame.display.set_mode(SCREEN, pygame.NOFRAME)
else:
	win = pygame.display.set_mode(SCREEN, pygame.NOFRAME | pygame.SCALED | pygame.FULLSCREEN)

clock = pygame.time.Clock()
FPS = 30

# COLORS *********************************************************************

WHITE = (255, 255, 255)
GRAY = (75, 75, 75)
BLUE = (30, 144, 255)

# IMAGES *********************************************************************

bg_img = pygame.image.load('Assets/bg.png')
bg_img = pygame.transform.scale(bg_img, (WIDTH, HEIGHT))

piano_img = pygame.image.load('Assets/piano.png')
piano_img = pygame.transform.scale(piano_img, (212, 212))

title_img = pygame.image.load('Assets/title.png')
title_img = pygame.transform.scale(title_img, (200, 50))

start_img = pygame.image.load('Assets/start.png')
start_img = pygame.transform.scale(start_img, (120, 40))
start_rect = start_img.get_rect(center=(WIDTH//2, HEIGHT-80))

overlay = pygame.image.load('Assets/red overlay.png')
overlay = pygame.transform.scale(overlay, (WIDTH, HEIGHT))

# MUSIC **********************************************************************

buzzer_fx = pygame.mixer.Sound('Sounds/piano-buzzer.mp3')

pygame.mixer.music.load('Sounds/piano-bgmusic.mp3')
pygame.mixer.music.set_volume(0.8)
pygame.mixer.music.play(loops=-1)

# FONTS **********************************************************************

score_font = pygame.font.Font('Fonts/Futura condensed.ttf', 32)
title_font = pygame.font.Font('Fonts/Alternity-8w7J.ttf', 30)
gameover_font = pygame.font.Font('Fonts/Alternity-8w7J.ttf', 40)

title_img = title_font.render('Piano Tiles', True, WHITE)

# BUTTONS ********************************************************************

close_img = pygame.image.load('Assets/closeBtn.png')
replay_img = pygame.image.load('Assets/replay.png')
sound_off_img = pygame.image.load("Assets/soundOffBtn.png")
sound_on_img = pygame.image.load("Assets/soundOnBtn.png")

close_btn = Button(close_img, (24, 24), WIDTH // 4 - 18, HEIGHT//2 + 120)
replay_btn = Button(replay_img, (36,36), WIDTH // 2  - 18, HEIGHT//2 + 115)
sound_btn = Button(sound_on_img, (24, 24), WIDTH - WIDTH // 4 - 18, HEIGHT//2 + 120)

# GROUPS & OBJECTS ***********************************************************

tile_group = pygame.sprite.Group()
square_group = pygame.sprite.Group()
text_group = pygame.sprite.Group()

time_counter = Counter(win, gameover_font)

# FUNCTIONS ******************************************************************

def get_speed(score):
	return 200 + 5 * score

def play_notes(notePath):
	pygame.mixer.Sound(notePath).play()

# NOTES **********************************************************************

with open('notes.json') as file:
	notes_dict = json.load(file)

# VARIABLES ******************************************************************

score = 0
high_score = 0
speed = 0

clicked = False
pos = None

home_page = True
game_page = False
game_over = False
sound_on = True

count = 0
overlay_index = 0

running = True
while running:
	pos = None

	count += 1
	if count % 100 == 0:
			square = Square(win)
			square_group.add(square)
			counter = 0

	win.blit(bg_img, (0,0))
	square_group.update()

	for event in pygame.event.get():
		if event.type == pygame.QUIT:
			running = False

		if event.type == pygame.KEYDOWN:
			if event.key == pygame.K_ESCAPE or \
				event.key == pygame.K_q:
				running = False

		if event.type == pygame.MOUSEBUTTONDOWN and not game_over:
			pos = event.pos

	if home_page:
		win.blit(piano_img, (WIDTH//8, HEIGHT//8))
		win.blit(start_img, start_rect)
		win.blit(title_img, (WIDTH // 2 - title_img.get_width() / 2 + 10, 300))

		if pos and start_rect.collidepoint(pos):
			home_page = False
			game_page = True

			x = random.randint(0, 3)
			t = Tile(x * TILE_WIDTH, -TILE_HEIGHT, win)
			tile_group.add(t)

			pos = None

			notes_list = notes_dict['2']
			note_count = 0
			pygame.mixer.set_num_channels(len(notes_list))

	if game_page:
		time_counter.update()
		if time_counter.count <= 0:
			for tile in tile_group:
				tile.update(speed)

				if pos:
					if tile.rect.collidepoint(pos):
						if tile.alive:
							tile.alive = False
							score += 1
							if score >= high_score:
								high_score = score
							

							note = notes_list[note_count].strip()
							th = Thread(target=play_notes, args=(f'Sounds/{note}.ogg', ))
							th.start()
							th.join()
							note_count = (note_count + 1) % len(notes_list)

							tpos = tile.rect.centerx - 10, tile.rect.y
							text = Text('+1', score_font, tpos, win)
							text_group.add(text)

						pos = None

				if tile.rect.bottom >= HEIGHT and tile.alive:
					if not game_over:
						tile.color = (255, 0, 0)
						buzzer_fx.play()
						game_over = True

			if pos:
				buzzer_fx.play()
				game_over = True

			if len(tile_group) > 0:
				t = tile_group.sprites()[-1]
				if t.rect.top + speed >= 0:
					x = random.randint(0, 3)
					y = -TILE_HEIGHT - (0 - t.rect.top)
					t = Tile(x * TILE_WIDTH, y, win)
					tile_group.add(t)

			text_group.update(speed)
			img1 = score_font.render(f'Score : {score}', True, WHITE)
			win.blit(img1, (70 - img1.get_width() / 2, 10))
			img2 = score_font.render(f'High : {high_score}', True, WHITE)
			win.blit(img2, (200 - img2.get_width() / 2, 10))
			for i in range(4):
				pygame.draw.line(win, WHITE, (TILE_WIDTH * i, 0), (TILE_WIDTH*i, HEIGHT), 1)

			speed = int(get_speed(score) * (FPS / 1000))

			if game_over:
				speed = 0

				if overlay_index > 20:
					win.blit(overlay, (0,0))

					img1 = gameover_font.render('Game over', True, WHITE)
					img2 = score_font.render(f'Score : {score}', True, WHITE)
					win.blit(img1, (WIDTH // 2 - img1.get_width() / 2, 180))
					win.blit(img2, (WIDTH // 2 - img2.get_width() / 2, 250))

					if close_btn.draw(win):
						running = False

					if replay_btn.draw(win):
						index = random.randint(1, len(notes_dict))
						notes_list = notes_dict[str(index)]
						note_count = 0
						pygame.mixer.set_num_channels(len(notes_list))

						text_group.empty()
						tile_group.empty()
						score = 0
						speed = 0
						overlay_index = 0
						game_over = False

						time_counter = Counter(win, gameover_font)

						x = random.randint(0, 3)
						t = Tile(x * TILE_WIDTH, -TILE_HEIGHT, win)
						tile_group.add(t)

					if sound_btn.draw(win):
						sound_on = not sound_on
				
						if sound_on:
							sound_btn.update_image(sound_on_img)
							pygame.mixer.music.play(loops=-1)
						else:
							sound_btn.update_image(sound_off_img)
							pygame.mixer.music.stop()
				else:
					overlay_index += 1
					if overlay_index % 3 == 0:
						win.blit(overlay, (0,0))

	pygame.draw.rect(win, BLUE, (0,0, WIDTH, HEIGHT), 2)
	clock.tick(FPS)
	pygame.display.update()

pygame.quit()

二.note_editor.py代码

# 导入josn文件
import json

twinkle_twinkle = ['c4','c4','g4','g4','a4','a4','g4',\
                'f4','f4','e4','e4','d4','d4','c4',\
                'g5','g5','f4','f4','e4','e4','d4',\
                'g5','g5','f4','f4','e4','e4','d4',\
                'c4','c4','g4','g4','a4','a4','g4',\
                'f4','f4','e4','e4','d4','d4','c4',\
                ]

happy_birthday = ["g4", "g4", "a4", "g4", "c5", "b4",\
                    "g4", "g4", "a4", "g4", "d5", "c5",\
                    "g4", "g4", "g5", "e5", "c5", "b4", "a4",\
                    "f5", "f5", "e5", "c5", "d5", "c5"]

jan_gan_man = ['c5', 'd5', 'e5', 'e5', 'e5', 'e5', 'e5',\
                'e5', 'e5', 'e5', 'e5', 'd5', 'e5', 'f5',\
                'e5', 'e5', 'e5', 'd5', 'd5', 'd5', 'b4',\
                'd5', 'c5', 'c5', 'g5', 'g5', 'g5', 'g5',\
                'g5', 'f-5', 'g5', 'g5', 'g5', 'f-5', 'a5',\
                'g5', 'f5', 'f5', 'f5', 'e5', 'e5', 'f5',\
                'd5', 'f5', 'e5', 'e5', 'e5', 'e5', 'e5',\
                'd5', 'g5', 'g5', 'g5', 'f5', 'f5', 'e5',\
                'e5', 'e5', 'd5', 'd5', 'd5', 'd5', 'b4',\
                'd5', 'c5', 'c5', 'd5', 'e5', 'e5', 'e5',\
                'e5', 'd5', 'e5', 'f5', 'e5', 'f5', 'g5',\
                'g5', 'g5', 'f5', 'e5', 'd5', 'f5', 'e5',\
                'e5', 'e5', 'd5', 'd5', 'd5', 'd5', 'b4',\
                'd5', 'c5', 'g5', 'g5', 'g5', 'g5', 'g5',\
                'g5', 'f-5', 'g5', 'g5', 'g5', 'f-5', 'a5',\
                'g5', 'f5', 'f5', 'f5', 'e5', 'e5', 'f5',\
                'df', 'e5', 'c5', 'b4', 'c5', 'b4', 'a5',\
                'b4', 'a5', 'g5', 'a5', 'c5', 'c5', 'd5',\
                'd5', 'e5', 'e5', 'd5', 'e5', 'f5']

o_mere_dil_ke_chain = ['a4', 'g4', 'a4', 'a4', 'g4', 'a4',\
                         'g4', 'e4', 'b4', 'g4', 'a4', 'a4',\
                         'g4', 'a4', 'g4', 'e4', 'g4', 'e4',\
                         'd4', 'd4', 'e4', 'e4', 'g4', 'g4',\
                         'a4', 'a4', 'b4', 'b4', 'g4', 'a4',\
                        'b4', 'b4', 'g4', 'a4', 'c5', 'b4',\
                        'a4', 'c5', 'b4', 'a4', 'c5', 'b4', 'a4']

naruto_theme = ['a4', 'b4', 'a4', 'g4', 'e4', 'g4', 'a4', 'd4',\
                'c4', 'd4', 'c4', 'a3', 'b3', 'a4', 'b4', 'a4',\
                'g4', 'e4', 'g4', 'a4', 'd4', 'c4', 'd4', 'c4',\
                'a3', 'a3', 'e4', 'd4', 'c4', 'a3', 'e4', 'd4',\
                'e4', 'a4', 'c5', 'b4', 'a4', 'g4', 'a4', 'e4',\
                'd4', 'e4', 'd4', 'b3', 'a3', 'a3', 'e4', 'd4',\
                'c4', 'a3', 'e4', 'd4', 'e4', 'a4', 'c5', 'b4',\
                'a4', 'g4', 'a4', 'e4', 'g4', 'a4', 'a4', 'b4',\
                'a4', 'g4', 'e4', 'g4', 'a4', 'd4', 'c4', 'd4',\
                'c4', 'a3', 'b3', 'g3', 'a4', 'b4', 'a4', 'g4',\
                'e4', 'g4', 'a4', 'd4', 'c4', 'd4', 'c4', 'a3',\
                'a3', 'e4', 'd4', 'c4', 'a3', 'e4', 'd4', 'e4',\
                'a4', 'c5', 'b4', 'a4', 'g4', 'a4', 'e4', 'd4',\
                'e4', 'd4', 'b3', 'a3', 'a3', 'e4', 'd4', 'c4',\
                'a3', 'e4', 'd4', 'e4', 'a4', 'c5', 'b4', 'a4',\
                'g4', 'a4', 'e4', 'g4', 'a4', 'a4', 'b4', 'a4',\
                'g4', 'e4', 'g4', 'a4', 'd4', 'c4', 'd4', 'c4',\
                'a3', 'b3', 'g3', 'a4', 'b4', 'a4', 'g4', 'e4',\
                'g4', 'a4', 'd4', 'c4', 'd4', 'c4', 'a3']

notes = {
    '1' : twinkle_twinkle,
    '2' : happy_birthday,
    '3' : jan_gan_man,
    '4' : o_mere_dil_ke_chain,
    '5' : naruto_theme
}

with open('notes.json', 'w') as file:
    json.dump(notes, file)

三.objects.py代码

import pygame
import random

SCREEN = WIDTH, HEIGHT = 288, 512
TILE_WIDTH = WIDTH // 4
TILE_HEIGHT = 130

WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
BLUE = (30, 144, 255)
BLUE2 = (2, 239, 239)
PURPLE = (191, 64, 191)

class Tile(pygame.sprite.Sprite):
	def __init__(self, x, y, win):
		super(Tile, self).__init__()

		self.win = win
		self.x, self.y = x, y
		self.color = BLACK
		self.alive = True

		self.surface = pygame.Surface((TILE_WIDTH, TILE_HEIGHT), pygame.SRCALPHA)
		self.rect = self.surface.get_rect()
		self.rect.x = x
		self.rect.y = y

		self.center = TILE_WIDTH//2, TILE_HEIGHT//2 + 15
		self.line_start = self.center[0], self.center[1]-18
		self.line_end = self.center[0], 20

	def update(self, speed):
		self.rect.y += speed
		if self.rect.y >= HEIGHT:
			self.kill()

		if self.alive:
			pygame.draw.rect(self.surface, self.color, (0,0, TILE_WIDTH, TILE_HEIGHT))
			pygame.draw.rect(self.surface, PURPLE, (0,0, TILE_WIDTH, TILE_HEIGHT), 4)
			pygame.draw.rect(self.surface, BLUE2, (0,0, TILE_WIDTH, TILE_HEIGHT), 2)
			pygame.draw.line(self.surface, BLUE, self.line_start, self.line_end, 3)
			pygame.draw.circle(self.surface, BLUE, self.center, 15, 3)
		else:
			pygame.draw.rect(self.surface, (0,0,0, 90), (0,0, TILE_WIDTH, TILE_HEIGHT))
			
		self.win.blit(self.surface, self.rect)

class Text(pygame.sprite.Sprite):
	def __init__(self, text, font, pos, win):
		super(Text, self).__init__()
		self.win = win

		self.x,self.y = pos
		self.initial = self.y
		self.image = font.render(text, True, (255, 255, 255))

	def update(self, speed):
		self.y += speed
		if self.y - self.initial >= 100:
			self.kill()

		self.win.blit(self.image, (self.x, self.y))

class Counter(pygame.sprite.Sprite):
	def __init__(self, win, font):
		super(Counter, self).__init__()

		self.win = win
		self.font = font
		self.index = 1
		self.count = 3

	def update(self):
		if self.index % 30 == 0:
			self.count -= 1

		self.index += 1

		if self.count > 0:
			self.image = self.font.render(f'{self.count}', True, (255, 255, 255))
			self.win.blit(self.image, (WIDTH//2-16, HEIGHT//2-25))

class Square(pygame.sprite.Sprite):
	def __init__(self, win):
		super(Square, self).__init__()

		self.win = win
		self.color = (255, 255, 255)
		self.speed = 3
		self.angle = 0

		self.side = random.randint(15, 40)
		x = random.randint(self.side, WIDTH-self.side)
		y = 0

		self.surface = pygame.Surface((self.side, self.side), pygame.SRCALPHA)
		self.rect = self.surface.get_rect(center=(x, y))

	def update(self):
		center = self.rect.center
		self.angle = (self.angle + self.speed) % 360
		image = pygame.transform.rotate(self.surface , self.angle)
		self.rect = image.get_rect()
		self.rect.center = center

		self.rect.y += 1.5

		if self.rect.top >= HEIGHT:
			self.kill()

		pygame.draw.rect(self.surface, self.color, (0,0, self.side, self.side), 4)
		pygame.draw.rect(self.surface, (30, 144, 255, 128), (2,2, self.side-4, self.side-4), 2)
		self.win.blit(image, self.rect)

class Button(pygame.sprite.Sprite):
	def __init__(self, img, scale, x, y):
		super(Button, self).__init__()
		
		self.scale = scale
		self.image = pygame.transform.scale(img, self.scale)
		self.rect = self.image.get_rect()
		self.rect.x = x
		self.rect.y = y

		self.clicked = False

	def update_image(self, img):
		self.image = pygame.transform.scale(img, self.scale)

	def draw(self, win):
		action = False
		pos = pygame.mouse.get_pos()
		if self.rect.collidepoint(pos):
			if pygame.mouse.get_pressed()[0] and not self.clicked:
				action = True
				self.clicked = True

			if not pygame.mouse.get_pressed()[0]:
				self.clicked = False

		win.blit(self.image, self.rect)
		return action

四.notes.json代码

{"1": ["c4", "c4", "g4", "g4", "a4", "a4", "g4", "f4", "f4", "e4", "e4", "d4", "d4", "c4", "g5", "g5", "f4", "f4", "e4", "e4", "d4", "g5", "g5", "f4", "f4", "e4", "e4", "d4", "c4", "c4", "g4", "g4", "a4", "a4", "g4", "f4", "f4", "e4", "e4", "d4", "d4", "c4"], "2": ["g4", "g4", "a4", "g4", "c5", "b4", "g4", "g4", "a4", "g4", "d5", "c5", "g4", "g4", "g5", "e5", "c5", "b4", "a4", "f5", "f5", "e5", "c5", "d5", "c5"], "3": ["c5", "d5", "e5", "e5", "e5", "e5", "e5", "e5", "e5", "e5", "e5", "d5", "e5", "f5", "e5", "e5", "e5", "d5", "d5", "d5", "b4", "d5", "c5", "c5", "g5", "g5", "g5", "g5", "g5", "f-5", "g5", "g5", "g5", "f-5", "a5", "g5", "f5", "f5", "f5", "e5", "e5", "f5", "d5", "f5", "e5", "e5", "e5", "e5", "e5", "d5", "g5", "g5", "g5", "f5", "f5", "e5", "e5", "e5", "d5", "d5", "d5", "d5", "b4", "d5", "c5", "c5", "d5", "e5", "e5", "e5", "e5", "d5", "e5", "f5", "e5", "f5", "g5", "g5", "g5", "f5", "e5", "d5", "f5", "e5", "e5", "e5", "d5", "d5", "d5", "d5", "b4", "d5", "c5", "g5", "g5", "g5", "g5", "g5", "g5", "f-5", "g5", "g5", "g5", "f-5", "a5", "g5", "f5", "f5", "f5", "e5", "e5", "f5", "df", "e5", "c5", "b4", "c5", "b4", "a5", "b4", "a5", "g5", "a5", "c5", "c5", "d5", "d5", "e5", "e5", "d5", "e5", "f5"], "4": ["a4", "g4", "a4", "a4", "g4", "a4", "g4", "e4", "b4", "g4", "a4", "a4", "g4", "a4", "g4", "e4", "g4", "e4", "d4", "d4", "e4", "e4", "g4", "g4", "a4", "a4", "b4", "b4", "g4", "a4", "b4", "b4", "g4", "a4", "c5", "b4", "a4", "c5", "b4", "a4", "c5", "b4", "a4"], "5": ["a4", "b4", "a4", "g4", "e4", "g4", "a4", "d4", "c4", "d4", "c4", "a3", "b3", "a4", "b4", "a4", "g4", "e4", "g4", "a4", "d4", "c4", "d4", "c4", "a3", "a3", "e4", "d4", "c4", "a3", "e4", "d4", "e4", "a4", "c5", "b4", "a4", "g4", "a4", "e4", "d4", "e4", "d4", "b3", "a3", "a3", "e4", "d4", "c4", "a3", "e4", "d4", "e4", "a4", "c5", "b4", "a4", "g4", "a4", "e4", "g4", "a4", "a4", "b4", "a4", "g4", "e4", "g4", "a4", "d4", "c4", "d4", "c4", "a3", "b3", "g3", "a4", "b4", "a4", "g4", "e4", "g4", "a4", "d4", "c4", "d4", "c4", "a3", "a3", "e4", "d4", "c4", "a3", "e4", "d4", "e4", "a4", "c5", "b4", "a4", "g4", "a4", "e4", "d4", "e4", "d4", "b3", "a3", "a3", "e4", "d4", "c4", "a3", "e4", "d4", "e4", "a4", "c5", "b4", "a4", "g4", "a4", "e4", "g4", "a4", "a4", "b4", "a4", "g4", "e4", "g4", "a4", "d4", "c4", "d4", "c4", "a3", "b3", "g3", "a4", "b4", "a4", "g4", "e4", "g4", "a4", "d4", "c4", "d4", "c4", "a3"]}

游戏效果展示

喜欢的话点个赞呗~

 源代码来自:Github上面的一位大佬

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/728934.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【机器学习 复习】第6章 支持向量机(SVM)

一、概念 1.支持向量机&#xff08;support vector machine&#xff0c;SVM&#xff09;&#xff1a; &#xff08;1&#xff09;基于统计学理论的监督学习方法&#xff0c;但不属于生成式模型&#xff0c;而是判别式模型。 &#xff08;2&#xff09;支持向量机在各个领域内的…

健康与生活助手:Kompas AI的高效应用

一、引言 在现代社会&#xff0c;随着生活节奏的加快和工作压力的增加&#xff0c;人们的健康问题日益凸显。健康管理已经成为每个人关注的重点。Kompas AI作为一款智能助手&#xff0c;通过其先进的人工智能技术&#xff0c;为用户提供全面的健康管理服务&#xff0c;帮助用户…

【C++知识点】类和对象:友元,运算符重载,多态

今天来继续了解类和对象&#xff01; PS.本博客参考b站up黑马程序员的相关课程&#xff0c;老师讲得非常非常好&#xff01; 封装 深拷贝与浅拷贝 浅拷贝&#xff1a;简单的赋值拷贝操作 深拷贝&#xff1a;在堆区重新申请空间&#xff0c;进行拷贝操作 首先&#xff0c…

【头歌】HBase扫描与过滤答案 解除复制粘贴限制

解除复制粘贴限制 当作者遇到这个限制的时候火气起来了三分&#xff0c;然后去网上搜索答案&#xff0c;然后发现了一位【碳烤小肥肠】居然不贴代码&#xff0c;XX链接&#xff0c;贴截图&#xff0c;瞬时火气冲顶&#xff0c;怒写此文 首先启动万能的控制台&#xff0c;然后C…

【Hadoop大数据技术】——期末复习(冲刺篇)

&#x1f4d6; 前言&#xff1a;快考试了&#xff0c;做篇期末总结&#xff0c;都是重点与必考点。 题型&#xff1a;简答题、编程题&#xff08;Java与Shell操作&#xff09;、看图分析题。题目大概率会从课后习题、实验里出。 课本&#xff1a; 目录 &#x1f552; 1. HDF…

数据结构--单链表(图文)

单链表的概念 在单链表中&#xff0c;每个元素&#xff08;称为节点&#xff09;包含两部分&#xff1a;一部分是存储数据的数据域&#xff0c;另一部分是存储下一个节点地址的指针域。这里的“单”指的是每个节点只有一个指向下一个节点的指针。 节点&#xff1a;链表中的基…

java-数据结构与算法-02-数据结构-01-数组

文章目录 1. 概述2. 动态数组3. 二维数组4. 局部性原理5. 越界检查6. 习题 1. 概述 定义 在计算机科学中&#xff0c;数组是由一组元素&#xff08;值或变量&#xff09;组成的数据结构&#xff0c;每个元素有至少一个索引或键来标识 In computer science, an array is a dat…

如何与精益管理咨询公司进行有效的沟通?

在现代企业管理中&#xff0c;精益管理咨询公司发挥着不可或缺的作用&#xff0c;它们通过提供专业的精益管理咨询服务&#xff0c;帮助企业优化运营流程&#xff0c;提升生产效率&#xff0c;降低成本&#xff0c;实现可持续发展。然而&#xff0c;与精益管理咨询公司进行有效…

软件测评中心▏软件安全测试的测试方法和注意事项介绍

软件安全测试是一种重要的测试活动&#xff0c;旨在评估和验证软件系统中潜在的安全风险&#xff0c;并提供可行的解决方案。通过对软件系统进行系统化的测试&#xff0c;可以及时发现和修复安全漏洞&#xff0c;保护软件系统的安全性。 软件安全测试的测试方法可以帮助测试人…

深度学习500问——Chapter11:迁移学习(4)

文章目录 11.3.8 流形学习方法 11.3.9 什么是finetune 11.3.10 finetune为什么有效 11.3.11 什么是网络自适应 11.3.12 GAN在迁移学习中的应用 参考文献 11.3.8 流形学习方法 什么是流行学习&#xff1f; 流行学习自从2000年在Science上被提出来以后&#xff0c;就成为了机器…

ASP.NET Core 中使用 Dapper 的 Oracle 存储过程输出参数

介绍 Oracle 数据库功能强大&#xff0c;在企业环境中使用广泛。在 ASP.NET Core 应用程序中使用 Oracle 存储过程时&#xff0c;处理输出参数可能具有挑战性。本教程将指导您完成使用 Dapper&#xff08;适用于 . NET 的轻量级 ORM&#xff08;对象关系映射器&#xff09;&am…

Python数据分析-对驾驶安全数据进行了预测

一、研究背景和意义 随着汽车保有量的不断增加&#xff0c;交通事故已成为全球范围内的重大公共安全问题。每年因交通事故造成的人员伤亡和财产损失给社会带来了巨大的负担。为了提高驾驶安全&#xff0c;减少交通事故的发生&#xff0c;许多研究致力于探索影响驾驶安全的因素…

模式分解的概念(上)-分解、无损连接性、保持函数依赖特性

一、分解的概念 1、分解的定义 2、判断一个关系模式的集合P是否为关系模式R的一个分解 只要满足以下三个条件&#xff0c;P就是R的一个分解 &#xff08;1&#xff09;P中所有关系模式属性集的并集是R的属性集 &#xff08;2&#xff09;P中所有不同的关系模式的属性集之间…

如何通过自定义模块DIY出专属个性化的CSDN主页?一招教你搞定!

个人主页&#xff1a;学习前端的小z 个人专栏&#xff1a;HTML5和CSS3悦读 本专栏旨在分享记录每日学习的前端知识和学习笔记的归纳总结&#xff0c;欢迎大家在评论区交流讨论&#xff01; 文章目录 &#x1f4af;如何通过HTMLCSS自定义模板diy出自己的个性化csdn主页&#x…

本地快速部署大语言模型开发平台Dify并实现远程访问保姆级教程

文章目录 前言1. Docker部署Dify2. 本地访问Dify3. Ubuntu安装Cpolar4. 配置公网地址5. 远程访问6. 固定Cpolar公网地址7. 固定地址访问 前言 本文主要介绍如何在Linux Ubuntu系统使用Docker快速部署大语言模型应用开发平台Dify,并结合cpolar内网穿透工具实现公网环境远程访问…

解决element-plus没有导出的成员FormInstance

使用element-plus的el-form时&#xff0c;报错“"element-plus"”没有导出的成员“FormInstance”。你是否指的是“FooterInstance”? 解决方法&#xff1a; 引入ElForm类型&#xff0c;在外重新定义FormInstance的类型为ElForm的实例类型 示例&#xff1a; import…

记录keras库中导入函数找不到的问题

1 . keras.preprocessing.text import Tokenizer 将最右边的点 " . " 修改成 " _ " : 2 . 相应函数/库找不到&#xff0c;在keras后面加一个api :

基于AT32_Work_Bench配置AT32工程

基于AT32_Work_Bench配置AT32工程 ✨AT32_Work_Bench工具是用来给AT32 MCU快速构建外设初始化工程软件&#xff0c;类似STM32的STM32CubeMX工具软件。 &#x1f4cd;AT32 TOOL系列工具下载地址&#xff1a;https://www.arterytek.com/cn/support/index.jsp?index4&#x1f3f7…

C# WPF入门学习主线篇(二十八)—— 使用集合(ObservableCollection)

C# WPF入门学习主线篇&#xff08;二十八&#xff09;—— 使用集合&#xff08;ObservableCollection&#xff09; 在WPF中&#xff0c;数据绑定是构建动态和响应式用户界面的关键。ObservableCollection是一个特别有用的集合类型&#xff0c;它不仅支持数据绑定&#xff0c;还…

基于Elementui组件,在vue中实现多种省市区前端静态JSON数据展示并支持与后端交互功能,提供后端名称label和id

基于Elementui组件&#xff0c;在vue中实现多种省市区前端静态数据&#xff08;本地JSON数据&#xff09;展示并支持与后端交互功能&#xff0c;提供后端名称label和id 话不多说&#xff0c;先上图 1.支持传递给后端选中省市区的id和名称&#xff0c;示例非常完整&#xff0c…