我正在尝试使用PyKDE,PyKDE.kdecore.KStandardDirs
是准确的。根据{{3}}使用两个字符串调用此方法,根据PyQt4文档,我可以使用标准Python str
而不是QString
。
这不起作用:
>> KStandardDirs.locate()("socket", "foo")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: KStandardDirs.locate(): not enough arguments
>>> KStandardDirs.locate("socket", "foo")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: KStandardDirs.locate(): argument 1 has unexpected type 'str'
我无法使用QString
,因为它似乎不存在:
>>> from PyQt4.QtCore import QString
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name QString
>>> from PyQt4.QtCore import *
>>> QString
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'QString' is not defined
我做错了什么?
答案 0 :(得分:2)
我怀疑PyKDE尚未准备好Python 3,至少就错误消息而言;尝试传入一个bytestring:
KStandardDirs.locate(b"socket", "foo")