Python 声音(“钟声") [英] Python Sound ("Bell")

查看:31
本文介绍了Python 声音(“钟声")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让 Python 程序在完成任务时发出哔哔声提醒我.目前,我使用 import os 然后使用命令行语音程序说处理完成".我宁愿它是一个简单的铃铛".

我知道有一个函数可以在 Cocoa 应用程序中使用,NSBeep,但我认为这与此无关.

我也试过

print(a)

但这没有用.

我使用的是 Mac,如果您无法从我的 Cocoa 评论中分辨出来,那么这可能会有所帮助.

解决方案

你试过了吗:

导入系统sys.stdout.write('a')sys.stdout.flush()

这在 Mac OS 10.5 上对我有用

实际上,我认为您最初的尝试也可以稍作修改:

print('a')

(你只需要在字符序列周围加上单引号).

I'd like to have a python program alert me when it has completed its task by making a beep noise. Currently, I use import os and then use a command line speech program to say "Process complete". I much rather it be a simple "bell."

I know that there's a function that can be used in Cocoa apps, NSBeep, but I don't think that has much anything to do with this.

I've also tried

print(a)

but that didn't work.

I'm using a Mac, if you couldn't tell by my Cocoa comment, so that may help.

解决方案

Have you tried :

import sys
sys.stdout.write('a')
sys.stdout.flush()

That works for me here on Mac OS 10.5

Actually, I think your original attempt works also with a little modification:

print('a')

(You just need the single quotes around the character sequence).

这篇关于Python 声音(“钟声")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆