I'm trying to use PyKDE, PyKDE.kdecore.KStandardDirs
to be precise. This method is called with two strings according to the documentation and according to the PyQt4 documentation, I can use standard Python str
s instead of QString
. This doesn't work:
我试着用PyKDE, PyKDE.kdecore。KStandardDirs精确。这个方法是根据文档和PyQt4文档的两个字符串来调用的,我可以使用标准的Python strs而不是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'
I can't use QString
either because it doesn't seem to exist:
我不能使用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
What am I doing wrong?
我做错了什么?
1 个解决方案
#1
2
I suspect that PyKDE is not yet Python 3 ready, at least as far as that error message is concerned; try passing in a bytestring instead:
我怀疑PyKDE还没有准备好Python 3,至少就那个错误消息而言是这样的;试着通过一个bytestring:
KStandardDirs.locate(b"socket", "foo")
#1
2
I suspect that PyKDE is not yet Python 3 ready, at least as far as that error message is concerned; try passing in a bytestring instead:
我怀疑PyKDE还没有准备好Python 3,至少就那个错误消息而言是这样的;试着通过一个bytestring:
KStandardDirs.locate(b"socket", "foo")