小编use*_*071的帖子

如何在Python 2.7中选择3个随机数?

假设我想生成数字1,4或7中的一个.

我该怎么做?我原本以为我可以写

import random
rand.randint(1,4,7)
Run Code Online (Sandbox Code Playgroud)

但这似乎不起作用.谢谢.

python random python-2.7

3
推荐指数
1
解决办法
9290
查看次数

我怎样才能找到Python Tic Tac Toe游戏的赢家?

到目前为止,我有一个程序,其中2个玩家可以点击以轮流放置X和O. 我不确定如何让该计划认可赢家/平局.如果你们能帮我制作一个能以任何方式在屏幕上显示胜利/平局的功能,我会永远爱你.谢谢.

from graphics import *

import sys


def player_o(win, center):
'''
Parameters:
- win: the window
'''
    outline_width = 5
    circle = Circle(center, boxsize/2)
    circle.setOutline('red')
    circle.setWidth(outline_width)
    circle.draw(win)


def player_x(win, p1x, p1y):
'''
Parameters:
- win: the window
'''
for i in range(2):
    deltaX = (-1) ** i * (boxsize / 2)
    deltaY = (boxsize / 2)
    line = Line(Point(p1x - deltaX, p1y - deltaY),
             Point(p1x + deltaX, p1y + deltaY))
    line.setFill('red')
    line.setWidth(5)
    line.draw(win)



def game():


global win
global boxsize …
Run Code Online (Sandbox Code Playgroud)

python graphics tic-tac-toe python-2.7

2
推荐指数
1
解决办法
1552
查看次数

标签 统计

python ×2

python-2.7 ×2

graphics ×1

random ×1

tic-tac-toe ×1