<p>使用wide函数<code>mciSendStringW</code>时,不应对字符串进行编码。因此,您的行应该简单地读<code>command = ' '.join(command)</code>。至少在我安装了python3.6的Windows10机器上是这样。在</p>
<p>要重新检查,可以运行下面的代码。第二个错误代码是296,这只是抱怨它是错误的文件类型,因为我们为测试创建了一个空文件。在</p>
<pre class="lang-py prettyprint-override"><code>from ctypes import c_buffer, windll
from sys import getfilesystemencoding
if __name__ == '__main__':
buf = c_buffer(255)
filesystemencoding = getfilesystemencoding()
filename = r'.\sauté.wav'
# create the file if it doesn't exist
file = open(filename, 'w+')
file.close()
# ASCII
command = 'open ' + filename
byte_string_command = command.encode(filesystemencoding)
errorCode = int(windll.winmm.mciSendStringA(byte_string_command, buf, 254, 0))
# errorCode should be 275: Cannot find the file
errorBuffer = c_buffer(255)
windll.winmm.mciGetErrorStringA(errorCode, errorBuffer, 254)
print("{}: {}".format(errorCode, errorBuffer.value.decode()))
# Unicode
errorCode = int(windll.winmm.mciSendStringW(command, buf, 254, 0))
# errorCode should be 296: The specified file cannot be played
errorBuffer = c_buffer(255)
windll.winmm.mciGetErrorStringA(errorCode, errorBuffer, 254)
print("{}: {}".format(errorCode, errorBuffer.value.decode()))
</code></pre>