我正在使用dbus从Songbird Media Player获取当前播放的歌曲,并且Metadata也从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)


如何将文件位置转换为普通字符串?

最佳答案

只要做str( your_dbus_string )

关于python - 将dbus.String转换为普通字符串,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2336127/

10-12 23:04