Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的 Rhythmbox 插件中,我需要从 xml 文件中读取数据。xml 文件与脚本相同。我读了这样的文件:
from xml.dom.minidom import parse doc = parse('sites.xml')
我收到一条错误消息,提示找不到该文件。我发现脚本在主文件夹中而不是在/usr/lib/rhythmbox/plugins/myfoder/. 这是我的脚本错误还是只是 Rhythmbox 的限制?
/usr/lib/rhythmbox/plugins/myfoder/
谢谢。
尝试添加直接地址。
import os from xml.dom.minidom import parse BASE_DIR = os.path.dirname(os.path.abspath(__file__)) xmlfile = os.path.join(BASE_DIR,'sites.xml') doc = parse(xmlfile)