"argument 1 has unexpected type 'str'"



我试图使用PyKDE, PyKDE.kdecore.KStandardDirs是准确的。根据文档和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

我做错了什么?

我怀疑PyKDE还没有准备好Python 3,至少就错误消息而言;试着传入一个字节串:

KStandardDirs.locate(b"socket", "foo")

相关内容

  • 没有找到相关文章

最新更新