2017-02-28 169 views
0

我寫了一個令人難以置信的簡單代碼來檢查模塊是否正常工作,但我一直在收到「必須是str,而不是字節」的錯誤。Python 3.6:必須是str,而不是播放模塊的字節錯誤

下面的代碼:

from playsound import playsound 

playsound('C:\\Users\\User\\Desktop\Müzik\\January\\The Rolling Stones - Paint It, Black (Official Lyric Video).mp3') 

而這裏的確切的錯誤:

Traceback (most recent call last): 
File "C:/Users/User/PycharmProjects/playsound/play_sound/__init__.py", line 3, in <module> 
playsound('C:\\Users\\User\\Desktop\Müzik\\January\\The Rolling Stones - Paint It, Black (Official Lyric Video).mp3') 
File "C:\Python36\lib\site-packages\playsound.py", line 34, in _playsoundWin 
winCommand('open "' + sound + '" alias', alias) 
File "C:\Python36\lib\site-packages\playsound.py", line 29, in winCommand 
'\n ' + errorBuffer.value) 
TypeError: must be str, not bytes 

欣賞的幫助。

+1

按照[頁的PyPI爲playsound模塊(https://pypi.python.org/pypi/playsound/1.2.1 ),「我只用Windows 7和OS X 10.11上的Python 2.7測試了它」。這告訴我它可能與Python 3.6不兼容。 –

+0

@RandomDavis是的,我同意。 Python 3.X以不同的方式處理「字節」和「字符串」。 – hashcode55

回答

相關問題