准确地说,我正在尝试使用PyKDE,PyKDE.kdecore.KStandardDirs。根据documentation使用两个字符串调用此方法,并且根据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我做错了什么?
发布于 2012-12-27 19:44:54
我怀疑PyKDE还没有准备好Python3,至少在这个错误消息方面是这样;试着传入一个字节字符串:
KStandardDirs.locate(b"socket", "foo")https://stackoverflow.com/questions/14054059
复制相似问题