繁体   English   中英

错误:TypeError: circle() 没有关键字 arguments

[英]Error: TypeError: circle() takes no keyword arguments

我正在尝试创建一个游戏,其中包含一个需要在单击某处后添加的圆圈,其他代码行工作正常,它只是代码行pygame.draw.circle(win, white, (105-circle_radius/2, 105-circle_radius/2), radius=circle_radius)返回的错误为:

 TypeError: circle() takes no keyword arguments

代码:

import pygame
pygame.init()

white = (255, 255, 255)
player_details = []
circle_radius = 100
WIDTH = 500
HEIGHT = 500


win = pygame.display.set_mode((WIDTH, HEIGHT))

(irrelevant code here)

def insert_input(slot_num, marker):
    board[slot_num] = marker
    print(board)


def circle_placement(x, y):
    if (31 <= x <= 179) and (31 <= y <= 179):
        slot1 = 1
        if board[1] == " ":
            insert_input(slot1, player_details[1])
            pygame.draw.circle(win, white, (105-circle_radius/2, 105-circle_radius/2), radius=circle_radius
        if board[1] != " ":
            print("Turn passed for attempting to Cheat!")

(irrelevant code here)

我尝试了其他形状并且一切正常,只是这个不起作用并返回错误:TypeError: circle() takes no keyword arguments,我试图将“circle_radius”更改为数字而不是变量但这不起作用,我尝试更改颜色但也不起作用。

我还没有从 inte.net 上找到任何答案,从我的研究中,当我这样做的时候,他们没有工作,所以我希望在这里找到答案。

pygame.draw.circle()半径参数不是关键字参数(删除radius= ):

pygame.draw.circle(win, white, (105-circle_radius/2, 105-circle_radius/2), radius=circle_radius)

pygame.draw.circle(win, white, (105-circle_radius/2, 105-circle_radius/2), circle_radius)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM