How to suppress console output in Python?

后端 未结 8 1820
北荒
北荒 2020-12-02 22:48

I\'m using Pygame/SDL\'s joystick module to get input from a gamepad. Every time I call its get_hat() method it prints to the console. This is problematic since

8条回答
  •  渐次进展
    2020-12-02 23:11

    If you are on a Debian or Ubuntu machine you can just simply recompile pygame without the messages.

    cd /tmp
    sudo apt-get build-dep pygame
    apt-get source pygame
    vim pygame-1.9.1release+dfsg/src/joystick.c
    # search for the printf("SDL.. messages and put a // in front
    apt-get source --compile pygame
    sudo dpkg -i python-pygame_1.9.1release+dfsg-9ubuntu1_amd64.deb
    

    Greetings Max

提交回复
热议问题