V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
alphab
V2EX  ›  Python

Python3 在 PyCharm 中 运行时如何设置播放提示音?

  •  
  •   alphab · Nov 14, 2017 · 4585 views
    This topic created in 3096 days ago, the information mentioned may be changed or developed.
    运行环境:Python3.6 ,MacOS 10.12 ,IDE:PyCharm 2017.2.4


    在 PyCharm 上运行 python3 代码,使用 pygame 设置提示音时,每次都会「自动弹出一个窗口」来播放提示音,直到程序运行结束,弹出的窗口才会自动关闭。

    有没有什么方法,能让提示音直接播放,而不是弹出一个类似播放器的窗口来播放?
    3 replies    2017-11-19 12:50:56 +08:00
    alphab
        1
    alphab  
    OP
       Nov 14, 2017
    有人知道吗?
    Liyuu
        2
    Liyuu  
       Nov 18, 2017
    可以试试 subprocess

    import subprocess
    audio_file = "/full/path/to/audio.wav"
    return_code = subprocess.call(["afplay", audio_file])


    出处: https://stackoverflow.com/questions/3498313/how-to-trigger-from-python-playing-of-a-wav-or-mp3-audio-file-on-a-mac
    alphab
        3
    alphab  
    OP
       Nov 19, 2017
    @Liyuu 真的可以了,谢谢🙏
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3488 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 11:40 · PVG 19:40 · LAX 04:40 · JFK 07:40
    ♥ Do have faith in what you're doing.