python使用tkinter库实现五子棋游戏


Posted in Python onJune 18, 2019

本文实例为大家分享了python实现五子棋游戏的具体代码,供大家参考,具体内容如下

一、运行截图:

python使用tkinter库实现五子棋游戏

python使用tkinter库实现五子棋游戏

python使用tkinter库实现五子棋游戏

python使用tkinter库实现五子棋游戏

二、代码

# 用数组定义一个棋盘,棋盘大小为 15×15
# 数组索引代表位置,
# 元素值代表该位置的状态:0代表没有棋子,1代表有黑棋,-1代表有白棋。
    
from tkinter import *
from tkinter.messagebox import *
 
 
class Chess(object):
 
 def __init__(self):
  #############
  # param #
  #######################################
  self.row, self.column = 15, 15
  self.mesh = 25
  self.ratio = 0.9
  self.board_color = "#CDBA96"
  self.header_bg = "#CDC0B0"
  self.btn_font = ("黑体", 12, "bold")
  self.step = self.mesh / 2
  self.chess_r = self.step * self.ratio
  self.point_r = self.step * 0.2
  self.matrix = [[0 for y in range(self.column)] for x in range(self.row)]
  self.is_start = False
  self.is_black = True
  self.last_p = None
 
  ###########
  # GUI #
  #######################################
  self.root = Tk()
  self.root.title("Gobang By Young")
  self.root.resizable(width=False, height=False)
 
  self.f_header = Frame(self.root, highlightthickness=0, bg=self.header_bg)
  self.f_header.pack(fill=BOTH, ipadx=10)
 
  self.b_start = Button(self.f_header, text="开始", command=self.bf_start, font=self.btn_font)
  self.b_restart = Button(self.f_header, text="重来", command=self.bf_restart, state=DISABLED, font=self.btn_font)
  self.l_info = Label(self.f_header, text="未开始", bg=self.header_bg, font=("楷体", 18, "bold"), fg="white")
  self.b_regret = Button(self.f_header, text="悔棋", command=self.bf_regret, state=DISABLED, font=self.btn_font)
  self.b_lose = Button(self.f_header, text="认输", command=self.bf_lose, state=DISABLED, font=self.btn_font)
 
  self.b_start.pack(side=LEFT, padx=20)
  self.b_restart.pack(side=LEFT)
  self.l_info.pack(side=LEFT, expand=YES, fill=BOTH, pady=10)
  self.b_lose.pack(side=RIGHT, padx=20)
  self.b_regret.pack(side=RIGHT)
 
  self.c_chess = Canvas(self.root, bg=self.board_color, width=(self.column + 1) * self.mesh,
        height=(self.row + 1) * self.mesh, highlightthickness=0)
  self.draw_board()
  self.c_chess.bind("<Button-1>", self.cf_board)
  self.c_chess.pack()
 
  self.root.mainloop()
 
 # 画x行y列处的网格
 def draw_mesh(self, x, y):
  # 一个倍率,由于tkinter操蛋的GUI,如果不加倍率,悔棋的时候会有一点痕迹,可以试试把这个改为1,就可以看到
  ratio = (1 - self.ratio) * 0.99 + 1
  center_x, center_y = self.mesh * (x + 1), self.mesh * (y + 1)
  # 先画背景色
  self.c_chess.create_rectangle(center_y - self.step, center_x - self.step,
          center_y + self.step, center_x + self.step,
          fill=self.board_color, outline=self.board_color)
  # 再画网格线,这里面a b c d是不同的系数,根据x,y不同位置确定,需要一定推导。
  a, b = [0, ratio] if y == 0 else [-ratio, 0] if y == self.row - 1 else [-ratio, ratio]
  c, d = [0, ratio] if x == 0 else [-ratio, 0] if x == self.column - 1 else [-ratio, ratio]
  self.c_chess.create_line(center_y + a * self.step, center_x, center_y + b * self.step, center_x)
  self.c_chess.create_line(center_y, center_x + c * self.step, center_y, center_x + d * self.step)
 
  # 有一些特殊的点要画小黑点
  if ((x == 3 or x == 11) and (y == 3 or y == 11)) or (x == 7 and y == 7):
   self.c_chess.create_oval(center_y - self.point_r, center_x - self.point_r,
          center_y + self.point_r, center_x + self.point_r, fill="black")
 
 # 画x行y列处的棋子,color指定棋子颜色
 def draw_chess(self, x, y, color):
  center_x, center_y = self.mesh * (x + 1), self.mesh * (y + 1)
  # 就是画个圆
  self.c_chess.create_oval(center_y - self.chess_r, center_x - self.chess_r,
         center_y + self.chess_r, center_x + self.chess_r,
         fill=color)
 
 # 画整个棋盘
 def draw_board(self):
  [self.draw_mesh(x, y) for y in range(self.column) for x in range(self.row)]
 
 # 在正中间显示文字
 def center_show(self, text):
  width, height = int(self.c_chess['width']), int(self.c_chess['height'])
  self.c_chess.create_text(int(width / 2), int(height / 2), text=text, font=("黑体", 30, "bold"), fill="red")
 
 # 开始的时候设置各个组件,变量的状态,初始化matrix矩阵,初始化棋盘,初始化信息
 def bf_start(self):
  self.set_btn_state("start")
  self.is_start = True
  self.is_black = True
  self.matrix = [[0 for y in range(self.column)] for x in range(self.row)]
  self.draw_board()
  self.l_info.config(text="黑方下棋")
 
 # 重来跟开始的效果一样
 def bf_restart(self):
  self.bf_start()
 
 # 用last_p来标识上一步的位置。先用网格覆盖掉棋子,操作相应的变量,matrix[x][y]要置空,只能悔一次棋
 def bf_regret(self):
  if not self.last_p:
   showinfo("提示", "现在不能悔棋")
   return
  x, y = self.last_p
  self.draw_mesh(x, y)
  self.matrix[x][y] = 0
  self.last_p = None
  self.trans_identify()
 
 # 几个状态改变,还有显示文字,没什么说的
 def bf_lose(self):
  self.set_btn_state("init")
  self.is_start = False
  text = self.ternary_operator("黑方认输", "白方认输")
  self.l_info.config(text=text)
  self.center_show("蔡")
 
 # Canvas的click事件
 def cf_board(self, e):
  # 找到离点击点最近的坐标
  x, y = int((e.y - self.step) / self.mesh), int((e.x - self.step) / self.mesh)
  # 找到该坐标的中心点位置
  center_x, center_y = self.mesh * (x + 1), self.mesh * (y + 1)
  # 计算点击点到中心的距离
  distance = ((center_x - e.y) ** 2 + (center_y - e.x) ** 2) ** 0.5
  # 如果距离不在规定的圆内,退出//如果这个位置已经有棋子,退出//如果游戏还没开始,退出
  if distance > self.step * 0.95 or self.matrix[x][y] != 0 or not self.is_start:
   return
  # 此时棋子的颜色,和matrix中该棋子的标识。
  color = self.ternary_operator("black", "white")
  tag = self.ternary_operator(1, -1)
  # 先画棋子,在修改matrix相应点的值,用last_p记录本次操作点
  self.draw_chess(x, y, color)
  self.matrix[x][y] = tag
  self.last_p = [x, y]
  # 如果赢了,则游戏结束,修改状态,中心显示某方获胜
  if self.is_win(x, y, tag):
   self.is_start = False
   self.set_btn_state("init")
   text = self.ternary_operator("黑方获胜", "白方获胜")
   self.center_show(text)
   return
  # 如果游戏继续,则交换棋手
  self.trans_identify()
 
 def is_win(self, x, y, tag):
  # 获取斜方向的列表
  def direction(i, j, di, dj, row, column, matrix):
   temp = []
   while 0 <= i < row and 0 <= j < column:
    i, j = i + di, j + dj
   i, j = i - di, j - dj
   while 0 <= i < row and 0 <= j < column:
    temp.append(matrix[i][j])
    i, j = i - di, j - dj
   return temp
 
  four_direction = []
  # 获取水平和竖直方向的列表
  four_direction.append([self.matrix[i][y] for i in range(self.row)])
  four_direction.append([self.matrix[x][j] for j in range(self.column)])
  # 获取斜方向的列表
  four_direction.append(direction(x, y, 1, 1, self.row, self.column, self.matrix))
  four_direction.append(direction(x, y, 1, -1, self.row, self.column, self.matrix))
 
  # 一一查看这四个方向,有没有满足五子连珠
  for v_list in four_direction:
   count = 0
   for v in v_list:
    if v == tag:
     count += 1
     if count == 5:
      return True
    else:
     count = 0
  return False
 
 # 设置四个按钮是否可以点击
 def set_btn_state(self, state):
  state_list = [NORMAL, DISABLED, DISABLED, DISABLED] if state == "init" else [DISABLED, NORMAL, NORMAL, NORMAL]
  self.b_start.config(state=state_list[0])
  self.b_restart.config(state=state_list[1])
  self.b_regret.config(state=state_list[2])
  self.b_lose.config(state=state_list[3])
 
 # 因为有很多和self.black相关的三元操作,所以就提取出来
 def ternary_operator(self, true, false):
  return true if self.is_black else false
 
 # 交换棋手
 def trans_identify(self):
  self.is_black = not self.is_black
  text = self.ternary_operator("黑方下棋", "白方下棋")
  self.l_info.config(text=text)
 
 
if __name__ == '__main__':
 Chess()

三、增加复盘和保存棋谱功能

直接贴可以运行的源码,添加了两个按键和一个页面。

python使用tkinter库实现五子棋游戏

python使用tkinter库实现五子棋游戏

python使用tkinter库实现五子棋游戏

# 用数组定义一个棋盘,棋盘大小为 15×15
# 数组索引代表位置,
# 元素值代表该位置的状态:0代表没有棋子,1代表有黑棋,-1代表有白棋。
 
from tkinter import *
from tkinter.messagebox import *
import os
 
TAG_BLACK = "1"
TAG_EMPTY = "."
TAG_WHITE = "0"
ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + os.path.sep + ".")
 
 
class Chess(object):
 
 def bf_save(self):
 
  path = os.path.join(ROOT_DIR, "record.txt")
  file = open(path, "w")
  for i in range(len(self.record)):
   x, y = self.record[i]
   file.write("{}: [{}, {}]\n".format("黑方" if i % 2 == 0 else "白方", x, y))
  file.close()
 
 def init_matrix(self):
  return [[TAG_EMPTY for y in range(self.column)] for x in range(self.row)]
 
 def __init__(self):
  #############
  # param #
  #######################################
  self.row, self.column = 15, 15
  self.mesh = 25
  self.ratio = 0.9
  self.board_color = "#CDBA96"
  self.header_bg = "#CDC0B0"
  self.btn_font = ("黑体", 12, "bold")
  self.step = self.mesh / 2
  self.chess_r = self.step * self.ratio
  self.point_r = self.step * 0.2
  self.matrix = self.init_matrix()
  self.is_start = False
  self.is_black = True
  self.record = []
 
  ###########
  # GUI #
  #######################################
  self.root = Tk()
  self.root.title("Gobang By Young")
  self.root.resizable(width=False, height=False)
 
  self.f_header = Frame(self.root, highlightthickness=0, bg=self.header_bg)
 
  self.b_start = Button(self.f_header, text="开始", command=self.bf_start, font=self.btn_font)
  self.b_restart = Button(self.f_header, text="重来", command=self.bf_restart, state=DISABLED, font=self.btn_font)
  self.l_info = Label(self.f_header, text="未开始", bg=self.header_bg, font=("楷体", 18, "bold"), fg="white")
  self.b_regret = Button(self.f_header, text="悔棋", command=self.bf_regret, state=DISABLED, font=self.btn_font)
  self.b_lose = Button(self.f_header, text="认输", command=self.bf_lose, state=DISABLED, font=self.btn_font)
 
  self.c_chess = Canvas(self.root, bg=self.board_color, width=(self.column + 1) * self.mesh,
        height=(self.row + 1) * self.mesh, highlightthickness=0)
  self.draw_board()
  self.c_chess.bind("<Button-1>", self.cf_board)
 
  self.b_record = Button(self.root, text="复 盘", command=self.bf_record, font=self.btn_font, bg="lightblue")
  self.b_save = Button(self.root, text="保 存", command=self.bf_save, font=self.btn_font, bg="lightblue")
 
  self.f_header.pack(side=TOP, fill=BOTH, ipadx=10)
  self.b_start.pack(side=LEFT, padx=20)
  self.b_restart.pack(side=LEFT)
  self.l_info.pack(side=LEFT, expand=YES, fill=BOTH, pady=10)
  self.b_lose.pack(side=RIGHT, padx=20)
  self.b_regret.pack(side=RIGHT)
 
  self.c_chess.pack(side=TOP)
 
  self.b_record.pack(side=TOP, expand=YES, fill=X)
  self.b_save.pack(side=TOP, expand=YES, fill=X)
 
  self.root.mainloop()
 
 # 画x行y列处的网格
 def draw_mesh(self, x, y):
  # 一个倍率,由于tkinter操蛋的GUI,如果不加倍率,悔棋的时候会有一点痕迹,可以试试把这个改为1,就可以看到
  ratio = (1 - self.ratio) * 0.99 + 1
  center_x, center_y = self.mesh * (x + 1), self.mesh * (y + 1)
  # 先画背景色
  self.c_chess.create_rectangle(center_y - self.step, center_x - self.step,
          center_y + self.step, center_x + self.step,
          fill=self.board_color, outline=self.board_color)
  # 再画网格线,这里面a b c d是不同的系数,根据x,y不同位置确定,需要一定推导。
  a, b = [0, ratio] if y == 0 else [-ratio, 0] if y == self.row - 1 else [-ratio, ratio]
  c, d = [0, ratio] if x == 0 else [-ratio, 0] if x == self.column - 1 else [-ratio, ratio]
  self.c_chess.create_line(center_y + a * self.step, center_x, center_y + b * self.step, center_x)
  self.c_chess.create_line(center_y, center_x + c * self.step, center_y, center_x + d * self.step)
 
  # 有一些特殊的点要画小黑点
  if ((x == 3 or x == 11) and (y == 3 or y == 11)) or (x == 7 and y == 7):
   self.c_chess.create_oval(center_y - self.point_r, center_x - self.point_r,
          center_y + self.point_r, center_x + self.point_r, fill="black")
 
 # 画x行y列处的棋子,color指定棋子颜色
 def draw_chess(self, x, y, color):
  center_x, center_y = self.mesh * (x + 1), self.mesh * (y + 1)
  # 就是画个圆
  self.c_chess.create_oval(center_y - self.chess_r, center_x - self.chess_r,
         center_y + self.chess_r, center_x + self.chess_r,
         fill=color)
 
 # 画整个棋盘
 def draw_board(self):
  [self.draw_mesh(x, y) for y in range(self.column) for x in range(self.row)]
 
 # 在正中间显示文字
 def center_show(self, text):
  width, height = int(self.c_chess['width']), int(self.c_chess['height'])
  self.c_chess.create_text(int(width / 2), int(height / 2), text=text, font=("黑体", 30, "bold"), fill="red")
 
 def bf_record(self):
  Record(self.record)
  pass
 
 # 开始的时候设置各个组件,变量的状态,初始化matrix矩阵,初始化棋盘,初始化信息
 def bf_start(self):
  self.set_btn_state("start")
  self.is_start = True
  self.is_black = True
  self.matrix = self.init_matrix()
  self.draw_board()
  self.record = []
  self.l_info.config(text="黑方下棋")
 
 # 重来跟开始的效果一样
 def bf_restart(self):
  self.record = []
  self.bf_start()
 
 # 用last_p来标识上一步的位置。先用网格覆盖掉棋子,操作相应的变量,matrix[x][y]要置空,只能悔一次棋
 def bf_regret(self):
  if len(self.record) == 0:
   showinfo("提示", "现在不能悔棋")
   return
  x, y = self.record[-1]
  self.draw_mesh(x, y)
  self.matrix[x][y] = TAG_EMPTY
  self.record = self.record[:-1]
  self.trans_identify()
 
 # 几个状态改变,还有显示文字,没什么说的
 def bf_lose(self):
  self.set_btn_state("init")
  self.is_start = False
  text = self.ternary_operator("黑方认输", "白方认输")
  self.l_info.config(text=text)
  self.center_show("蔡")
 
 def go_chess(self, x, y):
  # 此时棋子的颜色,和matrix中该棋子的标识。
  color = self.ternary_operator("black", "white")
  tag = self.ternary_operator(TAG_BLACK, TAG_WHITE)
  # 先画棋子,在修改matrix相应点的值,用last_p记录本次操作点
  self.draw_chess(x, y, color)
  self.matrix[x][y] = tag
  self.record.append([x, y])
  # 如果赢了,则游戏结束,修改状态,中心显示某方获胜
  if self.is_win(x, y, tag):
   self.is_start = False
   self.set_btn_state("init")
   text = self.ternary_operator("黑方获胜", "白方获胜")
   self.center_show(text)
   return
  # 如果游戏继续,则交换棋手
  self.trans_identify()
 
 # Canvas的click事件
 def cf_board(self, e):
  # 找到离点击点最近的坐标
  x, y = int((e.y - self.step) / self.mesh), int((e.x - self.step) / self.mesh)
  # 找到该坐标的中心点位置
  center_x, center_y = self.mesh * (x + 1), self.mesh * (y + 1)
  # 计算点击点到中心的距离
  distance = ((center_x - e.y) ** 2 + (center_y - e.x) ** 2) ** 0.5
  # 如果距离不在规定的圆内,退出//如果这个位置已经有棋子,退出//如果游戏还没开始,退出
  if distance > self.step * 0.95 or self.matrix[x][y] != TAG_EMPTY or not self.is_start:
   return
  self.go_chess(x, y)
 
 def is_win(self, x, y, tag):
  # 获取斜方向的列表
  def direction(i, j, di, dj, row, column, matrix):
   temp = []
   while 0 <= i < row and 0 <= j < column:
    i, j = i + di, j + dj
   i, j = i - di, j - dj
   while 0 <= i < row and 0 <= j < column:
    temp.append(matrix[i][j])
    i, j = i - di, j - dj
   return temp
 
  four_direction = []
  # 获取水平和竖直方向的列表
  four_direction.append([self.matrix[i][y] for i in range(self.row)])
  four_direction.append([self.matrix[x][j] for j in range(self.column)])
  # 获取斜方向的列表
  four_direction.append(direction(x, y, 1, 1, self.row, self.column, self.matrix))
  four_direction.append(direction(x, y, 1, -1, self.row, self.column, self.matrix))
 
  # 一一查看这四个方向,有没有满足五子连珠
  for v_list in four_direction:
   if tag * 5 in "".join(v_list):
    return True
  return False
 
 # 设置四个按钮是否可以点击
 def set_btn_state(self, state):
  state_list = [NORMAL, DISABLED, DISABLED, DISABLED] if state == "init" else [DISABLED, NORMAL, NORMAL, NORMAL]
  self.b_start.config(state=state_list[0])
  self.b_restart.config(state=state_list[1])
  self.b_regret.config(state=state_list[2])
  self.b_lose.config(state=state_list[3])
 
 # 因为有很多和self.black相关的三元操作,所以就提取出来
 def ternary_operator(self, true, false):
  return true if self.is_black else false
 
 # 交换棋手
 def trans_identify(self):
  self.is_black = not self.is_black
  text = self.ternary_operator("黑方下棋", "白方下棋")
  self.l_info.config(text=text)
 
 def print_process(self):
  pass
 
 
class Record(object):
 
 def __init__(self, record):
  #############
  # param #
  #######################################
  self.row, self.column = 15, 15
  self.mesh = 25
  self.ratio = 0.9
  self.board_color = "#CDBA96"
  self.header_bg = "#CDC0B0"
  self.btn_font = ("黑体", 12, "bold")
  self.step = self.mesh / 2
  self.chess_r = self.step * self.ratio
  self.point_r = self.step * 0.2
  ###########
  self.is_black = True
  self.index = -1
  self.record = record
  ###########
  # GUI #
  #######################################
  self.root = Tk()
  self.root.title("复盘")
  self.root.resizable(width=False, height=False)
  self.root.bind("<Key>", self.kf_step)
 
  self.f_header = Frame(self.root, highlightthickness=0, bg=self.header_bg)
  self.l_info = Label(self.f_header, text="未开始", bg=self.header_bg, font=("楷体", 18, "bold"), fg="white")
 
  self.c_chess = Canvas(self.root, bg=self.board_color, width=(self.column + 1) * self.mesh,
        height=(self.row + 1) * self.mesh, highlightthickness=0)
  self.draw_board()
 
  self.f_header.pack(fill=BOTH, ipadx=10)
  self.l_info.pack(side=LEFT, expand=YES, fill=BOTH, pady=10)
  self.c_chess.pack()
 
  self.root.mainloop()
 
 def kf_step(self, e):
  if e.keycode not in [37, 39]:
   return
  if e.keycode == 37:
   if self.index == -1:
    self.l_info.config(text="已经走到最开始了")
    return
   x, y = self.record[self.index]
   self.draw_mesh(x, y)
   if self.index == 0:
    self.l_info.config(text="未开始")
   else:
    self.l_info.config(text="黑方走棋" if self.is_black else "白方走棋")
   self.is_black = not self.is_black
   self.index -= 1
   if self.index > 0:
    x, y = self.record[self.index]
    color = "white" if self.is_black else "black"
    self.draw_chess(x, y, color, "red")
 
  elif e.keycode == 39:
   if self.index == len(self.record) - 1:
    self.l_info.config(text="已经走到最末尾了")
    return
   self.index += 1
   x, y = self.record[self.index]
   color = "black" if self.is_black else "white"
   self.draw_chess(x, y, color, "red")
   if self.index > 0:
    x, y = self.record[self.index - 1]
    color = "white" if self.is_black else "black"
    self.draw_chess(x, y, color)
   self.l_info.config(text="黑方走棋" if self.is_black else "白方走棋")
   self.is_black = not self.is_black
  else:
   pass
 
 # 画x行y列处的网格
 def draw_mesh(self, x, y):
  # 一个倍率,由于tkinter操蛋的GUI,如果不加倍率,悔棋的时候会有一点痕迹,可以试试把这个改为1,就可以看到
  ratio = (1 - self.ratio) * 0.99 + 1
  center_x, center_y = self.mesh * (x + 1), self.mesh * (y + 1)
  # 先画背景色
  self.c_chess.create_rectangle(center_y - self.step, center_x - self.step,
          center_y + self.step, center_x + self.step,
          fill=self.board_color, outline=self.board_color)
  # 再画网格线,这里面a b c d是不同的系数,根据x,y不同位置确定,需要一定推导。
  a, b = [0, ratio] if y == 0 else [-ratio, 0] if y == self.row - 1 else [-ratio, ratio]
  c, d = [0, ratio] if x == 0 else [-ratio, 0] if x == self.column - 1 else [-ratio, ratio]
  self.c_chess.create_line(center_y + a * self.step, center_x, center_y + b * self.step, center_x)
  self.c_chess.create_line(center_y, center_x + c * self.step, center_y, center_x + d * self.step)
 
  # 有一些特殊的点要画小黑点
  if ((x == 3 or x == 11) and (y == 3 or y == 11)) or (x == 7 and y == 7):
   self.c_chess.create_oval(center_y - self.point_r, center_x - self.point_r,
          center_y + self.point_r, center_x + self.point_r, fill="black")
 
 # 画x行y列处的棋子,color指定棋子颜色
 def draw_chess(self, x, y, color, outline="black"):
  center_x, center_y = self.mesh * (x + 1), self.mesh * (y + 1)
  # 就是画个圆
  self.c_chess.create_oval(center_y - self.chess_r, center_x - self.chess_r,
         center_y + self.chess_r, center_x + self.chess_r,
         fill=color, outline=outline)
 
 # 画整个棋盘
 def draw_board(self):
  [self.draw_mesh(x, y) for y in range(self.column) for x in range(self.row)]
 
 # 在正中间显示文字
 def center_show(self, text):
  width, height = int(self.c_chess['width']), int(self.c_chess['height'])
  self.c_chess.create_text(int(width / 2), int(height / 2), text=text, font=("黑体", 30, "bold"), fill="red")
 
 # 开始的时候设置各个组件,变量的状态,初始化matrix矩阵,初始化棋盘,初始化信息
 
 
if __name__ == '__main__':
 Chess()

 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Python 相关文章推荐
python冒泡排序算法的实现代码
Nov 21 Python
Python开发的单词频率统计工具wordsworth使用方法
Jun 25 Python
Python中struct模块对字节流/二进制流的操作教程
Jan 21 Python
Pycharm学习教程(3) 代码运行调试
May 03 Python
Python数据分析之双色球基于线性回归算法预测下期中奖结果示例
Feb 08 Python
Python迭代器和生成器定义与用法示例
Feb 10 Python
python将每个单词按空格分开并保存到文件中
Mar 19 Python
完美解决Pycharm无法导入包的问题 Unresolved reference
May 18 Python
利用Python查看微信共同好友功能的实现代码
Apr 24 Python
python网络应用开发知识点浅析
May 28 Python
Flask框架学习笔记之路由和反向路由详解【图文与实例】
Aug 12 Python
selenium+python实现基本自动化测试的示例代码
Jan 27 Python
Python基础学习之基本数据结构详解【数字、字符串、列表、元组、集合、字典】
Jun 18 #Python
python 弹窗提示警告框MessageBox的实例
Jun 18 #Python
python实现五子棋小程序
Jun 18 #Python
Python 实现还原已撤回的微信消息
Jun 18 #Python
PyQt4编程之让状态栏显示信息的方法
Jun 18 #Python
Python直接赋值、浅拷贝与深度拷贝实例分析
Jun 18 #Python
python实现五子棋游戏
Jun 18 #Python
You might like
php 生成自动创建文件夹并上传文件的示例代码
2014/03/07 PHP
php实现的替换敏感字符串类实例
2014/09/22 PHP
thinkPHP5分页功能实现方法分析
2017/10/25 PHP
GridView中获取被点击行中的DropDownList和TextBox中的值
2013/07/18 Javascript
常用的几段javascript代码分享
2014/03/25 Javascript
jQuery前端框架easyui使用Dialog时bug处理
2014/12/05 Javascript
jQuery中extend函数详解
2015/02/13 Javascript
jquery专业的导航菜单特效代码分享
2015/08/29 Javascript
jQuery css() 方法动态修改CSS属性
2016/09/25 Javascript
移动端界面的适配
2017/01/11 Javascript
Angularjs 实现动态添加控件功能
2017/05/25 Javascript
jquery在启动页面时,自动加载数据的实例
2018/01/22 jQuery
利用vue.js把静态json绑定bootstrap的table方法
2018/08/28 Javascript
JS如何实现网站中PC端和手机端自动识别并跳转对应的代码
2020/01/08 Javascript
python实现k均值算法示例(k均值聚类算法)
2014/03/16 Python
Python批量按比例缩小图片脚本分享
2015/05/21 Python
Python读写配置文件的方法
2015/06/03 Python
怎么使用pipenv管理你的python项目
2018/03/12 Python
关于Python正则表达式 findall函数问题详解
2018/03/22 Python
对pandas中iloc,loc取数据差别及按条件取值的方法详解
2018/11/06 Python
python单例设计模式实现解析
2020/01/07 Python
tensorflow 利用expand_dims和squeeze扩展和压缩tensor维度方式
2020/02/07 Python
浅谈Pytorch torch.optim优化器个性化的使用
2020/02/20 Python
LORAC官网:美国彩妆品牌
2019/08/27 全球购物
优秀员工获奖感言
2014/03/01 职场文书
简历中个人自我评价分享
2014/03/15 职场文书
护士上岗前培训自我鉴定
2014/04/20 职场文书
公安局副政委班子个人对照检查材料
2014/10/04 职场文书
出售房屋协议书范本
2014/10/06 职场文书
教育项目合作协议书格式
2014/10/17 职场文书
2015年化验员工作总结
2015/04/10 职场文书
幼儿园园长工作总结2015
2015/05/25 职场文书
2016党员干部政治学习心得体会
2016/01/23 职场文书
python基础之文件操作
2021/10/24 Python
Python中的程序流程控制语句
2022/02/24 Python
Win11如何设置右键单击显示所有选项?Win11右键单击显示所有选项设置教程
2022/04/08 数码科技