利用Python如何制作贪吃蛇及AI版贪吃蛇详解


Posted in Python onAugust 24, 2020

用python制作普通贪吃蛇

哈喽,大家不知道是上午好还是中午好还是下午好还是晚上好!

贪吃蛇,应该是90后小时候的记忆(连我这个00后也不例外),今天,我们就用python这款编程语言来实现贪吃蛇

系统:所有都可以

需导入模块:

  • random
  • pygame
  • pygame.locals
  • sys

下载以上模块指令:

random和sys是Python自带的,我们只需要下载pygame即可

下载pygame:

在开始菜单输入“cmd”回车打开,输入``指令:pip install pygame

苹果电脑需要改成:pip3 install pygame

下载好后,打开python的shell界面,输入import pygame,回车,如果没报错,及代表安装完成。

接下来什么都不说,直接奉上代码(恕我没写注释):

import random
import pygame
import sys
from pygame.locals import *
 
Snakespeed = 17
Window_Width = 800
Window_Height = 500
Cell_Size = 20 # Width and height of the cells
# Ensuring that the cells fit perfectly in the window. eg if cell size was
# 10 and window width or windowheight were 15 only 1.5 cells would
# fit.
assert Window_Width % Cell_Size == 0, "Window width must be a multiple of cell size."
# Ensuring that only whole integer number of cells fit perfectly in the window.
assert Window_Height % Cell_Size == 0, "Window height must be a multiple of cell size."
Cell_W = int(Window_Width / Cell_Size) # Cell Width
Cell_H = int(Window_Height / Cell_Size) # Cellc Height
 
 
White = (255, 255, 255)
Black = (0, 0, 0)
Red = (255, 0, 0) # Defining element colors for the program.
Green = (0, 255, 0)
DARKGreen = (0, 155, 0)
DARKGRAY = (40, 40, 40)
YELLOW = (255, 255, 0)
Red_DARK = (150, 0, 0)
BLUE = (0, 0, 255)
BLUE_DARK = (0, 0, 150)
 
 
BGCOLOR = Black # Background color
 
 
UP = 'up'
DOWN = 'down' # Defining keyboard keys.
LEFT = 'left'
RIGHT = 'right'
 
HEAD = 0 # Syntactic sugar: index of the snake's head
 
 
def main():
 global SnakespeedCLOCK, DISPLAYSURF, BASICFONT
 
 pygame.init()
 SnakespeedCLOCK = pygame.time.Clock()
 DISPLAYSURF = pygame.display.set_mode((Window_Width, Window_Height))
 BASICFONT = pygame.font.Font('freesansbold.ttf', 18)
 pygame.display.set_caption('Snake')
 
 showStartScreen()
 while True:
 runGame()
 showGameOverScreen()
 
 
def runGame():
 # Set a random start point.
 startx = random.randint(5, Cell_W - 6)
 starty = random.randint(5, Cell_H - 6)
 wormCoords = [{'x': startx, 'y': starty},
   {'x': startx - 1, 'y': starty},
   {'x': startx - 2, 'y': starty}]
 direction = RIGHT
 
 # Start the apple in a random place.
 apple = getRandomLocation()
 
 while True: # main game loop
 for event in pygame.event.get(): # event handling loop
  if event.type == QUIT:
  terminate()
  elif event.type == KEYDOWN:
  if (event.key == K_LEFT) and direction != RIGHT:
   direction = LEFT
  elif (event.key == K_RIGHT) and direction != LEFT:
   direction = RIGHT
  elif (event.key == K_UP) and direction != DOWN:
   direction = UP
  elif (event.key == K_DOWN) and direction != UP:
   direction = DOWN
  elif event.key == K_ESCAPE:
   terminate()
 
 # check if the Snake has hit itself or the edge
 if wormCoords[HEAD]['x'] == -1 or wormCoords[HEAD]['x'] == Cell_W or wormCoords[HEAD]['y'] == -1 or wormCoords[HEAD]['y'] == Cell_H:
  return # game over
 for wormBody in wormCoords[1:]:
  if wormBody['x'] == wormCoords[HEAD]['x'] and wormBody['y'] == wormCoords[HEAD]['y']:
  return # game over
 
 # check if Snake has eaten an apply
 if wormCoords[HEAD]['x'] == apple['x'] and wormCoords[HEAD]['y'] == apple['y']:
  # don't remove worm's tail segment
  apple = getRandomLocation() # set a new apple somewhere
 else:
  del wormCoords[-1] # remove worm's tail segment
 
 # move the worm by adding a segment in the direction it is moving
 if direction == UP:
  newHead = {'x': wormCoords[HEAD]['x'],
   'y': wormCoords[HEAD]['y'] - 1}
 elif direction == DOWN:
  newHead = {'x': wormCoords[HEAD]['x'],
   'y': wormCoords[HEAD]['y'] + 1}
 elif direction == LEFT:
  newHead = {'x': wormCoords[HEAD][
  'x'] - 1, 'y': wormCoords[HEAD]['y']}
 elif direction == RIGHT:
  newHead = {'x': wormCoords[HEAD][
  'x'] + 1, 'y': wormCoords[HEAD]['y']}
 wormCoords.insert(0, newHead)
 DISPLAYSURF.fill(BGCOLOR)
 drawGrid()
 drawWorm(wormCoords)
 drawApple(apple)
 drawScore(len(wormCoords) - 3)
 pygame.display.update()
 SnakespeedCLOCK.tick(Snakespeed)
 
 
def drawPressKeyMsg():
 pressKeySurf = BASICFONT.render('Press a key to play.', True, White)
 pressKeyRect = pressKeySurf.get_rect()
 pressKeyRect.topleft = (Window_Width - 200, Window_Height - 30)
 DISPLAYSURF.blit(pressKeySurf, pressKeyRect)
 
 
def checkForKeyPress():
 if len(pygame.event.get(QUIT)) > 0:
 terminate()
 keyUpEvents = pygame.event.get(KEYUP)
 if len(keyUpEvents) == 0:
 return None
 if keyUpEvents[0].key == K_ESCAPE:
 terminate()
 return keyUpEvents[0].key
 
 
def showStartScreen():
 titleFont = pygame.font.Font('freesansbold.ttf', 100)
 titleSurf1 = titleFont.render('Snake!', True, White, DARKGreen)
 degrees1 = 0
 degrees2 = 0
 while True:
 DISPLAYSURF.fill(BGCOLOR)
 rotatedSurf1 = pygame.transform.rotate(titleSurf1, degrees1)
 rotatedRect1 = rotatedSurf1.get_rect()
 rotatedRect1.center = (Window_Width / 2, Window_Height / 2)
 DISPLAYSURF.blit(rotatedSurf1, rotatedRect1)
 
 drawPressKeyMsg()
 
 if checkForKeyPress():
  pygame.event.get() # clear event queue
  return
 pygame.display.update()
 SnakespeedCLOCK.tick(Snakespeed)
 degrees1 += 3 # rotate by 3 degrees each frame
 degrees2 += 7 # rotate by 7 degrees each frame
 
 
def terminate():
 pygame.quit()
 sys.exit()
 
 
def getRandomLocation():
 return {'x': random.randint(0, Cell_W - 1), 'y': random.randint(0, Cell_H - 1)}
 
 
def showGameOverScreen():
 gameOverFont = pygame.font.Font('freesansbold.ttf', 100)
 gameSurf = gameOverFont.render('Game', True, White)
 overSurf = gameOverFont.render('Over', True, White)
 gameRect = gameSurf.get_rect()
 overRect = overSurf.get_rect()
 gameRect.midtop = (Window_Width / 2, 10)
 overRect.midtop = (Window_Width / 2, gameRect.height + 10 + 25)
 
 DISPLAYSURF.blit(gameSurf, gameRect)
 DISPLAYSURF.blit(overSurf, overRect)
 drawPressKeyMsg()
 pygame.display.update()
 pygame.time.wait(500)
 checkForKeyPress() # clear out any key presses in the event queue
 
 while True:
 if checkForKeyPress():
  pygame.event.get() # clear event queue
  return
 
 
def drawScore(score):
 scoreSurf = BASICFONT.render('Score: %s' % (score), True, White)
 scoreRect = scoreSurf.get_rect()
 scoreRect.topleft = (Window_Width - 120, 10)
 DISPLAYSURF.blit(scoreSurf, scoreRect)
 
 
def drawWorm(wormCoords):
 for coord in wormCoords:
 x = coord['x'] * Cell_Size
 y = coord['y'] * Cell_Size
 wormSegmentRect = pygame.Rect(x, y, Cell_Size, Cell_Size)
 pygame.draw.rect(DISPLAYSURF, DARKGreen, wormSegmentRect)
 wormInnerSegmentRect = pygame.Rect(
  x + 4, y + 4, Cell_Size - 8, Cell_Size - 8)
 pygame.draw.rect(DISPLAYSURF, Green, wormInnerSegmentRect)
 
 
def drawApple(coord):
 x = coord['x'] * Cell_Size
 y = coord['y'] * Cell_Size
 appleRect = pygame.Rect(x, y, Cell_Size, Cell_Size)
 pygame.draw.rect(DISPLAYSURF, Red, appleRect)
 
 
def drawGrid():
 for x in range(0, Window_Width, Cell_Size): # draw vertical lines
 pygame.draw.line(DISPLAYSURF, DARKGRAY, (x, 0), (x, Window_Height))
 for y in range(0, Window_Height, Cell_Size): # draw horizontal lines
 pygame.draw.line(DISPLAYSURF, DARKGRAY, (0, y), (Window_Width, y))
 
 
if __name__ == '__main__':
 try:
 main()
 except SystemExit:
 pass

以上是贪吃蛇的全部代码,接下来,我们来制作AI版贪吃蛇。

用python制作AI版贪吃蛇

AI版贪吃蛇,即让系统自己玩贪吃蛇,一句话:自己玩自己。下面开始:

系统:什么都可以

需导入的模块:

  • pygame
  • sys
  • time
  • random

如果你已经下载好了pygame,即可直接开始。

还是什么都不说,直接奉上代码(这次有注释)

#coding: utf-8
import pygame,sys,time,random
from pygame.locals import *
# 定义颜色变量
redColour = pygame.Color(255,0,0)
blackColour = pygame.Color(0,0,0)
whiteColour = pygame.Color(255,255,255)
greenColour = pygame.Color(0,255,0)
headColour = pygame.Color(0,119,255)

#注意:在下面所有的除法中,为了防止pygame输出偏差,必须取除数(//)而不是单纯除法(/)

# 蛇运动的场地长宽,因为第0行,HEIGHT行,第0列,WIDTH列为围墙,所以实际是13*13
HEIGHT = 15
WIDTH = 15
FIELD_SIZE = HEIGHT * WIDTH
# 蛇头位于snake数组的第一个元素
HEAD = 0

# 用数字代表不同的对象,由于运动时矩阵上每个格子会处理成到达食物的路径长度,
# 因此这三个变量间需要有足够大的间隔(>HEIGHT*WIDTH)来互相区分
# 小写一般是坐标,大写代表常量
FOOD = 0
UNDEFINED = (HEIGHT + 1) * (WIDTH + 1)
SNAKE = 2 * UNDEFINED

# 由于snake是一维数组,所以对应元素直接加上以下值就表示向四个方向移动
LEFT = -1
RIGHT = 1
UP = -WIDTH#一维数组,所以需要整个宽度都加上才能表示上下移动
DOWN = WIDTH 

# 错误码
ERR = -2333

# 用一维数组来表示二维的东西
# board表示蛇运动的矩形场地
# 初始化蛇头在(1,1)的地方
# 初始蛇长度为1
board = [0] * FIELD_SIZE #[0,0,0,……]
snake = [0] * (FIELD_SIZE+1)
snake[HEAD] = 1*WIDTH+1
snake_size = 1
# 与上面变量对应的临时变量,蛇试探性地移动时使用
tmpboard = [0] * FIELD_SIZE
tmpsnake = [0] * (FIELD_SIZE+1)
tmpsnake[HEAD] = 1*WIDTH+1
tmpsnake_size = 1

# food:食物位置初始在(4, 7)
# best_move: 运动方向
food = 4 * WIDTH + 7
best_move = ERR

# 运动方向数组,游戏分数(蛇长)
mov = [LEFT, RIGHT, UP, DOWN]           
score = 1 

# 检查一个cell有没有被蛇身覆盖,没有覆盖则为free,返回true
def is_cell_free(idx, psize, psnake):
 return not (idx in psnake[:psize]) 

# 检查某个位置idx是否可向move方向运动
def is_move_possible(idx, move):
 flag = False
 if move == LEFT:
  #因为实际范围是13*13,[1,13]*[1,13],所以idx为1时不能往左跑,此时取余为1所以>1
  flag = True if idx%WIDTH > 1 else False
 elif move == RIGHT:
  #这里的<WIDTH-2跟上面是一样的道理
  flag = True if idx%WIDTH < (WIDTH-2) else False
 elif move == UP:
  #这里向上的判断画图很好理解,因为在[1,13]*[1,13]的实际运动范围外,还有个
  #大框是围墙,就是之前说的那几个行列,下面判断向下运动的条件也是类似的
  flag = True if idx > (2*WIDTH-1) else False
 elif move == DOWN:
  flag = True if idx < (FIELD_SIZE-2*WIDTH) else False
 return flag
# 重置board
# board_BFS后,UNDEFINED值都变为了到达食物的路径长度
# 如需要还原,则要重置它
def board_reset(psnake, psize, pboard):
 for i in range(FIELD_SIZE):
  if i == food:
   pboard[i] = FOOD
  elif is_cell_free(i, psize, psnake): # 该位置为空
   pboard[i] = UNDEFINED
  else: # 该位置为蛇身
   pboard[i] = SNAKE
 
# 广度优先搜索遍历整个board,
# 计算出board中每个非SNAKE元素到达食物的路径长度
def board_BFS(pfood, psnake, pboard):
 queue = []
 queue.append(pfood)
 inqueue = [0] * FIELD_SIZE
 found = False
 # while循环结束后,除了蛇的身体,
 # 其它每个方格中的数字为从它到食物的曼哈顿间距
 while len(queue)!=0: 
  idx = queue.pop(0)#初始时idx是食物的坐标 
  if inqueue[idx] == 1: continue
  inqueue[idx] = 1
  for i in range(4):#左右上下
   if is_move_possible(idx, mov[i]):
    if idx + mov[i] == psnake[HEAD]:
     found = True
    if pboard[idx+mov[i]] < SNAKE: # 如果该点不是蛇的身体
     if pboard[idx+mov[i]] > pboard[idx]+1:#小于的时候不管,不然会覆盖已有的路径数据
      pboard[idx+mov[i]] = pboard[idx] + 1
     if inqueue[idx+mov[i]] == 0:
      queue.append(idx+mov[i])
 return found

# 从蛇头开始,根据board中元素值,
# 从蛇头周围4个领域点中选择最短路径
def choose_shortest_safe_move(psnake, pboard):
 best_move = ERR
 min = SNAKE
 for i in range(4):
  if is_move_possible(psnake[HEAD], mov[i]) and pboard[psnake[HEAD]+mov[i]]<min:
   #这里判断最小和下面的函数判断最大,都是先赋值,再循环互相比较
   min = pboard[psnake[HEAD]+mov[i]]
   best_move = mov[i]
 return best_move

# 从蛇头开始,根据board中元素值,
# 从蛇头周围4个领域点中选择最远路径
def choose_longest_safe_move(psnake, pboard):
 best_move = ERR
 max = -1
 for i in range(4):
  if is_move_possible(psnake[HEAD], mov[i]) and pboard[psnake[HEAD]+mov[i]]<UNDEFINED and pboard[psnake[HEAD]+mov[i]]>max:
   max = pboard[psnake[HEAD]+mov[i]]
   best_move = mov[i]
 return best_move

# 检查是否可以追着蛇尾运动,即蛇头和蛇尾间是有路径的
# 为的是避免蛇头陷入死路
# 虚拟操作,在tmpboard,tmpsnake中进行
def is_tail_inside():
 global tmpboard, tmpsnake, food, tmpsnake_size
 tmpboard[tmpsnake[tmpsnake_size-1]] = 0 # 虚拟地将蛇尾变为食物(因为是虚拟的,所以在tmpsnake,tmpboard中进行)
 tmpboard[food] = SNAKE # 放置食物的地方,看成蛇身
 result = board_BFS(tmpsnake[tmpsnake_size-1], tmpsnake, tmpboard) # 求得每个位置到蛇尾的路径长度
 for i in range(4): # 如果蛇头和蛇尾紧挨着,则返回False。即不能follow_tail,追着蛇尾运动了
  if is_move_possible(tmpsnake[HEAD], mov[i]) and tmpsnake[HEAD]+mov[i]==tmpsnake[tmpsnake_size-1] and tmpsnake_size>3:
   result = False
 return result

# 让蛇头朝着蛇尾运行一步
# 不管蛇身阻挡,朝蛇尾方向运行
def follow_tail():
 global tmpboard, tmpsnake, food, tmpsnake_size
 tmpsnake_size = snake_size
 tmpsnake = snake[:]
 board_reset(tmpsnake, tmpsnake_size, tmpboard) # 重置虚拟board
 tmpboard[tmpsnake[tmpsnake_size-1]] = FOOD # 让蛇尾成为食物
 tmpboard[food] = SNAKE # 让食物的地方变成蛇身
 board_BFS(tmpsnake[tmpsnake_size-1], tmpsnake, tmpboard) # 求得各个位置到达蛇尾的路径长度
 tmpboard[tmpsnake[tmpsnake_size-1]] = SNAKE # 还原蛇尾
 return choose_longest_safe_move(tmpsnake, tmpboard) # 返回运行方向(让蛇头运动1步)

# 在各种方案都不行时,随便找一个可行的方向来走(1步),
def any_possible_move():
 global food , snake, snake_size, board
 best_move = ERR
 board_reset(snake, snake_size, board)
 board_BFS(food, snake, board)
 min = SNAKE

 for i in range(4):
  if is_move_possible(snake[HEAD], mov[i]) and board[snake[HEAD]+mov[i]]<min:
   min = board[snake[HEAD]+mov[i]]
   best_move = mov[i]
 return best_move
 
#转换数组函数
def shift_array(arr, size):
 for i in range(size, 0, -1):
  arr[i] = arr[i-1]

def new_food():#随机函数生成新的食物
 global food, snake_size
 cell_free = False
 while not cell_free:
  w = random.randint(1, WIDTH-2)
  h = random.randint(1, HEIGHT-2)
  food = WIDTH*h + w
  cell_free = is_cell_free(food, snake_size, snake)
 pygame.draw.rect(playSurface,redColour,Rect(18*(food//WIDTH), 18*(food%WIDTH),18,18))

# 真正的蛇在这个函数中,朝pbest_move走1步
def make_move(pbest_move):
 global snake, board, snake_size, score
 shift_array(snake, snake_size)
 snake[HEAD] += pbest_move
 p = snake[HEAD]
 for body in snake:#画蛇,身体,头,尾
  pygame.draw.rect(playSurface,whiteColour,Rect(18*(body//WIDTH), 18*(body%WIDTH),18,18))
 pygame.draw.rect(playSurface,greenColour,Rect(18*(snake[snake_size-1]//WIDTH),18*(snake[snake_size-1]%WIDTH),18,18))
 pygame.draw.rect(playSurface,headColour,Rect(18*(p//WIDTH), 18*(p%WIDTH),18,18))
 #下面一行是把初始情况会出现的第一个白块bug填掉
 pygame.draw.rect(playSurface,(255,255,0),Rect(0,0,18,18))
 # 刷新pygame显示层
 pygame.display.flip() 
 
 # 如果新加入的蛇头就是食物的位置
 # 蛇长加1,产生新的食物,重置board(因为原来那些路径长度已经用不上了)
 if snake[HEAD] == food:
  board[snake[HEAD]] = SNAKE # 新的蛇头
  snake_size += 1
  score += 1
  if snake_size < FIELD_SIZE: new_food()
 else: # 如果新加入的蛇头不是食物的位置
  board[snake[HEAD]] = SNAKE # 新的蛇头
  board[snake[snake_size]] = UNDEFINED # 蛇尾变为UNDEFINED,黑色
  pygame.draw.rect(playSurface,blackColour,Rect(18*(snake[snake_size]//WIDTH),18*(snake[snake_size]%WIDTH),18,18))
  # 刷新pygame显示层
  pygame.display.flip() 

# 虚拟地运行一次,然后在调用处检查这次运行可否可行
# 可行才真实运行。
# 虚拟运行吃到食物后,得到虚拟下蛇在board的位置
def virtual_shortest_move():
 global snake, board, snake_size, tmpsnake, tmpboard, tmpsnake_size, food
 tmpsnake_size = snake_size
 tmpsnake = snake[:] # 如果直接tmpsnake=snake,则两者指向同一处内存
 tmpboard = board[:] # board中已经是各位置到达食物的路径长度了,不用再计算
 board_reset(tmpsnake, tmpsnake_size, tmpboard)
 
 food_eated = False
 while not food_eated:
  board_BFS(food, tmpsnake, tmpboard) 
  move = choose_shortest_safe_move(tmpsnake, tmpboard)
  shift_array(tmpsnake, tmpsnake_size)
  tmpsnake[HEAD] += move # 在蛇头前加入一个新的位置
  # 如果新加入的蛇头的位置正好是食物的位置
  # 则长度加1,重置board,食物那个位置变为蛇的一部分(SNAKE)
  if tmpsnake[HEAD] == food:
   tmpsnake_size += 1
   board_reset(tmpsnake, tmpsnake_size, tmpboard) # 虚拟运行后,蛇在board的位置
   tmpboard[food] = SNAKE
   food_eated = True
  else: # 如果蛇头不是食物的位置,则新加入的位置为蛇头,最后一个变为空格
   tmpboard[tmpsnake[HEAD]] = SNAKE
   tmpboard[tmpsnake[tmpsnake_size]] = UNDEFINED

# 如果蛇与食物间有路径,则调用本函数
def find_safe_way():
 global snake, board
 safe_move = ERR
 # 虚拟地运行一次,因为已经确保蛇与食物间有路径,所以执行有效
 # 运行后得到虚拟下蛇在board中的位置,即tmpboard
 virtual_shortest_move() # 该函数唯一调用处
 if is_tail_inside(): # 如果虚拟运行后,蛇头蛇尾间有通路,则选最短路运行(1步)
  return choose_shortest_safe_move(snake, board)
 safe_move = follow_tail() # 否则虚拟地follow_tail 1步,如果可以做到,返回true
 return safe_move


#初始化pygame
pygame.init()
#定义一个变量用来控制游戏速度
fpsClock = pygame.time.Clock()
# 创建pygame显示层
playSurface = pygame.display.set_mode((270,270))
pygame.display.set_caption('贪吃蛇')
# 绘制pygame显示层
playSurface.fill(blackColour)
#初始化食物
pygame.draw.rect(playSurface,redColour,Rect(18*(food//WIDTH), 18*(food%WIDTH),18,18))

while True:
 for event in pygame.event.get():#循环监听键盘和退出事件
  if event.type == QUIT:#如果点了关闭
   print(score)#游戏结束后打印分数
   pygame.quit()
   sys.exit()
  elif event.type == KEYDOWN:#如果esc键被按下
   if event.key==K_ESCAPE:
    print(score)#游戏结束后打印分数
    pygame.quit()
    sys.exit()
 # 刷新pygame显示层
 pygame.display.flip() 
 #画围墙,255,255,0是黄色,边框是36是因为,pygame矩形是以边为初始,向四周填充边框
 pygame.draw.rect(playSurface,(255,255,0),Rect(0,0,270,270),36)
 # 重置距离
 board_reset(snake, snake_size, board)
 # 如果蛇可以吃到食物,board_BFS返回true
 # 并且board中除了蛇身(=SNAKE),其它的元素值表示从该点运动到食物的最短路径长
 if board_BFS(food, snake, board):
  best_move = find_safe_way() # find_safe_way的唯一调用处
 else:
  best_move = follow_tail()
 if best_move == ERR:
  best_move = any_possible_move()
 # 上面一次思考,只得出一个方向,运行一步
 if best_move != ERR: make_move(best_move)
 else:
  print(score)#游戏结束后打印分数
  break
 # 控制游戏速度
 fpsClock.tick(20)#20看上去速度正好

ok,这就是今天的全部内容866!

到此这篇关于利用Python如何制作贪吃蛇及AI版贪吃蛇的文章就介绍到这了,更多相关Python制作贪吃蛇及AI版贪吃蛇内容请搜索三水点靠木以前的文章或继续浏览下面的相关文章希望大家以后多多支持三水点靠木!

Python 相关文章推荐
python实现斐波那契递归函数的方法
Sep 08 Python
Python实现获取磁盘剩余空间的2种方法
Jun 07 Python
python字典快速保存于读取的方法
Mar 23 Python
python微信公众号之关键词自动回复
Jun 15 Python
Python定时任务随机时间执行的实现方法
Aug 14 Python
PyCharm2018 安装及破解方法实现步骤
Sep 09 Python
python SocketServer源码深入解读
Sep 17 Python
OpenCV读取与写入图片的实现
Oct 13 Python
PyCharm安装PyQt5及其工具(Qt Designer、PyUIC、PyRcc)的步骤详解
Nov 02 Python
Python常用扩展插件使用教程解析
Nov 02 Python
Python之Sklearn使用入门教程
Feb 19 Python
Python实现智慧校园自动评教全新版
Jun 18 Python
python实现自动清理重复文件
Aug 24 #Python
anaconda3安装及jupyter环境配置全教程
Aug 24 #Python
Python+pyftpdlib实现局域网文件互传
Aug 24 #Python
实例代码讲解Python 线程池
Aug 24 #Python
详解python UDP 编程
Aug 24 #Python
PyTorch如何搭建一个简单的网络
Aug 24 #Python
Python pysnmp使用方法及代码实例
Aug 24 #Python
You might like
PHP Memcached + APC + 文件缓存封装实现代码
2010/03/11 PHP
php中3des加密代码(完全与.net中的兼容)
2012/08/02 PHP
PHP获取文件后缀名的三个函数
2012/10/15 PHP
PHP error_log()将错误信息写入一个文件(定义和用法)
2013/10/25 PHP
PHP字符串逆序排列实现方法小结【strrev函数,二分法,循环法,递归法】
2017/01/13 PHP
PHP实现的mysql操作类【MySQL与MySQLi方式】
2017/10/07 PHP
php语言注释,单行注释和多行注释
2018/01/21 PHP
PHP中非常有用却鲜有人知的函数集锦
2019/08/17 PHP
DHTML 中的绝对定位
2006/11/26 Javascript
JQuery的一些小应用收集
2010/03/27 Javascript
!DOCTYPE声明对JavaScript的影响分析
2010/04/12 Javascript
js获取select标签的值且兼容IE与firefox
2013/12/30 Javascript
node.js中的path.basename方法使用说明
2014/12/09 Javascript
js实现简单div拖拽功能实例
2015/05/12 Javascript
jQuery拖动布局其结果保存到数据库
2015/10/09 Javascript
Bootstrap每天必学之表单
2015/11/23 Javascript
浅析jQuery事件之on()方法绑定多个选择器,多个事件
2016/04/27 Javascript
原生js实现自由拖拽弹窗代码demo
2016/06/29 Javascript
JavaScript学习笔记整理_关于表达式和语句
2016/09/19 Javascript
DOM 事件的深入浅出(一)
2016/12/05 Javascript
详解基于Vue-cli搭建的项目如何和后台交互
2018/06/29 Javascript
对Vue2 自定义全局指令Vue.directive和指令的生命周期介绍
2018/08/30 Javascript
微信小程序分享小程序码的生成(带参数)以及参数的获取
2020/03/25 Javascript
JavaScript使用prototype属性实现继承操作示例
2020/05/22 Javascript
jquery实现拖拽添加元素功能
2020/12/01 jQuery
[46:00]DOTA2上海特级锦标赛主赛事日 - 2 胜者组第一轮#4EG VS Fnatic第一局
2016/03/03 DOTA
Python version 2.7 required, which was not found in the registry
2014/08/26 Python
python模块之re正则表达式详解
2017/02/03 Python
Python除法之传统除法、Floor除法及真除法实例详解
2019/05/23 Python
python groupby 函数 as_index详解
2019/12/16 Python
css3实例教程 一款纯css3实现的发光屏幕旋转特效
2014/12/07 HTML / CSS
如何用JQuery进行表单验证
2013/05/29 面试题
用Java语言将一个键盘输入的数字转化成中文输出
2013/01/25 面试题
导游词之香港-太平山顶
2019/10/18 职场文书
Python基础之pandas数据合并
2021/04/27 Python
docker compose 部署 golang 的 Athens 私有代理问题
2022/04/28 Servers