无法理解为什么随机位置按钮的代码为';t工作(python、pygame)

无法理解为什么随机位置按钮的代码为';t工作(python、pygame),python,python-3.x,pygame,Python,Python 3.x,Pygame,在我的脑海里,一切都是有道理的。我不明白为什么当我点击按钮时它不工作。我相信问题在于这些文字行 mouse = pygame.mouse.get_pos() if mouse[0] >= rand_x <= player_size and mouse[1] >= rand_y <= player_size: sys.exit()""" mouse=pygame.mouse.get_po

在我的脑海里,一切都是有道理的。我不明白为什么当我点击按钮时它不工作。我相信问题在于这些文字行

        mouse = pygame.mouse.get_pos()
        if mouse[0] >= rand_x <= player_size and mouse[1] >= rand_y <= player_size:
            sys.exit()"""
mouse=pygame.mouse.get_pos()
如果此语句中的鼠标[0]>=rand\u x=rand\u y:

mouse[0] >= rand_x <= player_size

mouse[0]>=rand_x=rand_x和rand_x如果你认为这就是你的问题所在,你打印出鼠标的值了吗?你得到了什么?欢迎来到SO。请澄清“不起作用”的含义。
mouse[0]>= rand_X and rand_x <= player_size
    rand_x <= mouse[0] <= rand_x+player_size