📄 152.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Robots" content="INDEX,NOFOLLOW">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<TITLE>Safari | Python Developer's Handbook -> Working with Sounds</TITLE>
<LINK REL="stylesheet" HREF="oreillyi/oreillyN.css">
</HEAD>
<BODY bgcolor="white" text="black" link="#990000" vlink="#990000" alink="#990000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" cellpadding=5 cellspacing=0 border=0 class="navtopbg"><tr><td><font size="1"><p class="navtitle"><a href="8.html" class="navtitle">Web Development</a> > <a href="0672319942.html" class="navtitle">Python Developer's Handbook</a> > <a href="148.html" class="navtitle">9. Other Advanced Topics</a> > <span class="nonavtitle">Working with Sounds</span></p></font></td><td align="right" valign="top" nowrap><font size="1"><a href="main.asp?list" class="safnavoff">See All Titles</a></font></td></tr></table>
<TABLE width=100% bgcolor=white border=0 cellspacing=0 cellpadding=5><TR><TD>
<TABLE border=0 width="100%" cellspacing=0 cellpadding=0><TR><td align=left width="15%" class="headingsubbarbg"><a href="151.html" title="Manipulating Images"><font size="1">< BACK</font></a></td><td align=center width="70%" class="headingsubbarbg"><font size="1"><a href="popanote.asp?pubui=oreilly&bookname=0672319942&snode=152" target="_blank" title="Make a public or private annnotation">Make Note</a> | <a href="152.html" title="Use a Safari bookmark to remember this section">Bookmark</a></font></td><td align=right width="15%" class="headingsubbarbg"><a href="153.html" title="Restricted Execution Mode"><font size="1">CONTINUE ></font></a></td></TR></TABLE>
<a href="5%2F31%2F2002+4%3A40%3A16+PM.html" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><font color=white size=1>152015024128143245168232148039199167010047123209178152124239215162148044238005059246049208</font><a href="read0.asp?bookname=0672319942&snode=152&now=5%2F31%2F2002+4%3A40%3A16+PM" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><br>
<FONT>
<h3>
Working with Sounds</h3>
<p>Python has many modules that can provide audio support for your programs by allowing you to listen to your favorite audio CDs and read/write audio files (such as <tT CLAss="monofont">.wav, .aifc,</tt> and so on). Next, I present some of the most important modules. However, keep in mind that other modules exist that are not mentioned here.</P>
<H4>
<TT clasS="monofont">winsound</TT> Module</H4>
<p>The <tt class="monofont">winsound</tt> module implements an interface that grants access to the sound-playing environment provided by <tt class="monofont">Windows</tt> Platforms. This module is able to play wave sound files (<tT clAss="monofont">.wav</tT>).</p>
<p>This module implements the function <tt ClasS="monofont">PlaySound,</TT> which has the following syntax: <Tt claSS="monofont">PlaySound(sound, flags).</TT>
</p>
<pre>
>>> import winsound
>>> winsound.PlaySound(r'C:\WINNT\Media\tada.wav', winsound.SND_FILENAME)
</PRE>
<P>The following <a namE="idx1073745276"></A>
<A Name="idx1073745277"></a>
<a name="idx1073745278"></a>
<a name="idx1073745279"></a>
<a namE="idx1073745280"></a>
<a Name="idx1073745281"></A>
<tt clAss="monofont">flag</tT> constants, which are also defined by this module, can be used as bitwise arguments to the <TT Class="monofont">PlaySound</TT> function:</P>
<BlockQUOTe>
<p>
<p>
<tT CLAss="monofont">SND_FILENAME
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -