我正在使用dbus从Songbird Media Player获取当前播放的歌曲。元数据也来自dbus对象。
出现错误的行是: -
audio_file = MP3(current_playing_track['location'], ID3=ID3)
错误是: -
Traceback (most recent call last):
File "./last.py", line 42, in <module>
audio_file = MP3(current_playing_track['location'], ID3=ID3)
File "/usr/lib/python2.6/dist-packages/mutagen/__init__.py", line 73, in __init__
self.load(filename, *args, **kwargs)
File "/usr/lib/python2.6/dist-packages/mutagen/id3.py", line 1949, in load
try: self.tags = ID3(filename, **kwargs)
File "/usr/lib/python2.6/dist-packages/mutagen/id3.py", line 74, in __init__
super(ID3, self).__init__(*args, **kwargs)
File "/usr/lib/python2.6/dist-packages/mutagen/_util.py", line 103, in __init__
super(DictProxy, self).__init__(*args, **kwargs)
File "/usr/lib/python2.6/dist-packages/mutagen/__init__.py", line 37, in __init__
self.load(*args, **kwargs)
File "/usr/lib/python2.6/dist-packages/mutagen/id3.py", line 109, in load
self.__fileobj = file(filename, 'rb')
IOError: [Errno 2] No such file or directory: dbus.String(u'file:///media/Misc/Songbird%20Library/Puddle%20Of%20Mudd/Puddle%20Of%20Mudd%20-%20Unknown%20Album%20-%20Spin%20You%20Around.mp3', variant_level=1)
如何将文件位置转换为普通字符串?
答案 0 :(得分:7)
只需str( your_dbus_string )