[Gif在输入语句后出现脚本崩溃

问题描述 投票:1回答:1

[我试图在我的家庭作业游戏中打印gif,如果有人获胜或失败,为此我有以下代码:

import shutil
import pyglet
import requests
import os

def gif():
    url = 'https://tenor.com/view/no-oh-no-nope-nah-not-really-gif-15162749.gif'
    filename = url.split('/')[-1]
    with open(filename, 'wb') as out_file:
        out_file.write(requests.get(url).content)
    os.rename('no-oh-no-nope-nah-not-really-gif-15162749.gif', 'michaelscott1.gif')

    animation = pyglet.image.load_animation('michaelscott1.gif')
    animSprite = pyglet.sprite.Sprite(animation)

    w = animSprite.width
    h = animSprite.height

    window = pyglet.window.Window(width=w, height=h)

    @window.event
    def on_draw():
        window.clear()
        animSprite.draw()

    pyglet.app.run()

gif()

如果运行它,程序将显示gif,当我关闭它时,该程序以退出代码0结尾。

如果在其后加上打印语句,它将显示gif,打印打印,然后以退出代码0结尾。

但是,如果我尝试在gif后面输入输入语句,则>]

input('>')

显示gif的python窗口崩溃。当我强制关闭它时,脚本退出,并得到以下返回语句:

Process finished with exit code 143 (interrupted by signal 15: SIGTERM)

解决方案是什么?

[我试图在我的家庭作业游戏中打印gif,如果有人赢了或输了,为此,我有这样的代码: ...

python pyglet
1个回答
0
投票

假设您切换到Python3 (您应该这样做)

© www.soinside.com 2019 - 2024. All rights reserved.