gpt4 book ai didi

python - "argument 1 has unexpected type ' 字符串 '"

转载 作者:行者123 更新时间:2023-12-01 05:51:37 24 4
gpt4 key购买 nike

我正在尝试使用 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

我做错了什么?

最佳答案

我怀疑 PyKDE 尚未准备好 Python 3,至少就该错误消息而言;尝试传入字节串:

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

关于python - "argument 1 has unexpected type ' 字符串 '",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14054059/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com