python - 为什么线程(使用 python)可以在 Windows 上工作,但不能在 Mac 上工作?
问题描述
每次我们尝试在 Mac 上运行代码时都会出现错误。它应该在游戏开始之前绘制一个“蛇”标签。这是为什么?其余代码是典型的蛇游戏代码,通常在任何地方都可以使用。为此,我们与 Pygame 合作。这是代码:
import threading
def draw_logo():
cord_list = ["71,100 129,100", "75,100 75,155",
"75,150 130,150", "125,150 125,205",
"125,200 71,200", "175,205 175,150",
"175,150 175,95", "175,95 225,155",
"225,150 225,95", "225,150 225,205",
"275,205 275,150", "275,150 275,96",
"275,100 325,100", "325,96 325,150",
"325,150 325,205", "275,150 325,150",
"375,205 375,150", "375,150 375,95",
"375,150 400,150", "400,150 425,95",
"400,150 425,205", "525,100 475,100",
"475,96 475,150", "475,150 475,205",
"475,200 525,200", "475,150 500,150"]
for cord in cord_list:
start, end = cord.split(" ",1)
pg.draw.line(window, malachite, tuple(map(int,start.split(","))), tuple(map(int,end.split(","))), 10)
time.sleep(0.05)
pg.display.update()
if stop_threads:
break
stop_threads = False
th_draw = threading.Thread(target=draw_logo)
th_draw.start()
#after a button is pressed, variable stop_threads = True to start the game immediately
stop_threads = True
这是错误消息:
pygame 2.0.1 (SDL 2.0.14, Python 3.7.9) 来自 pygame 社区的问候。pygame.org/contribute.html -[MTLIOAccelCommandBuffer validate]:208: 断言失败“使用未提交的编码器提交命令缓冲区”后端终止或断开连接。使用“停止/重新启动”重新启动。
解决方案
推荐阅读
- c++ - 为什么有符号字符可以保存比 127 更大的值?
- ios - Swift - 将结构分配给 var 结果始终为零
- kotlin - Kotlin:如何展平 Hashmap 列表
- c# - 将 ef 核心迁移到 3.1.0 后 ToAsyncEnumerable.ToList() 抛出错误
- python - 我需要为特定用户 Django 更新图像
- python-3.x - 将多个文件夹中的excel数据提取到DataFrame,并将每行的文件夹名称提取到Dataframe
- r - view_zoom_manual xmin 和 xmax 使用日期 r ggplot
- angular - Angular 8 - 渲染 ng 模板之一
- python-3.x - 将 obspy.taup 与从 .txt 文件中获得的变量一起使用
- python - 为什么允许“set”时,PyCharm 认为“Set[str]”类型不兼容?