Python 类自值错误,预期类型“str”得到了 Tuple[str],而 azure ClientSecretCredential

阿里

我创建了一个类并尝试将它的一个值分配给需要字符串的东西,但是它说它得到了一个Tuple[str],但我不明白怎么做?

from azure.identity import ClientSecretCredential


class ServicePrincipal:
    """
    Service Principal class is used to authorise the service
    """
    def __init__(self):
        self.tenant_id = "123-xyz",
        self.client_id = "123-abc",
        self.client_secret = "123-lmn",

    def credentials(self):
        """
        Returns a ClientServiceCredential object using service principal details
        :return:
        """
        # ISSUE IS HERE 
        return ClientSecretCredential(
            tenant_id=self.tenant_id, # <---- Getting Tuple[str]
            client_id=self.client_id, # <---- Getting Tuple[str]
            client_secret=self.client_secret, # <---- Getting Tuple[str]
        )

如果我将字符串直接复制粘贴到参数中就好了。所以这self.value以某种方式引起了问题?

瓦莱里奥·普雷蒂

您应该删除此处的逗号:

def __init__(self):
        self.tenant_id = "123-xyz",  # remove the comma
        self.client_id = "123-abc",  # remove the comma
        self.client_secret = "123-lmn",  # remove the comma

逗号使变量成为元组

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何使用 Azure.Identity.ClientSecretCredential 访问 Azure 队列?

Python Dataframe简单平均错误:TypeError:预期的元组,得到了str

Azure Python SDK错误

ClientSecretCredential 身份验证失败:配置问题阻止身份验证 - 检查来自服务器的错误消息以了解详细信息

Python TypeError-预期的字节数,但是在尝试创建签名时得到了“ str”

Azure 函数:执行 python 类

Python Azure队列,出现错误

Python:类型错误:预期的 str、bytes 或 bytearray,而不是 int

类型错误:预期为 float32,而是得到了类型为 'str' 的 'auto'

Pymoo Python:类型错误:_evaluate() 得到了一个意外的关键字参数“算法”

断言错误:意外的类型。预期的“列表”在使用 Pulumi Azure Native 创建 Azure Databricks 时出现“<class 'str'>”错误

Microsoft Azure上的Python FastCGI错误

对于python中的以下代码,我得到了错误--AttributeError:'str'对象没有属性'next'

类型错误:在 Python 中打开文件时需要一个整数(得到类型 str)

类型错误:需要一个整数(得到类型 str)Python

django-“类型错误。预期的pk值,收到了str”错误

Python Azure WebJob导入错误-无法导入Python扩展模块

fluter错误预期值为'Map <dynamic,dynamic>'类型的值,但得到了'List <dynamic>'类型的值之一

预期类型,得到了模板

类型错误:__init__() 在 python 的 argparser 中得到了一个意外的关键字参数“选择”

错误:预期为类型,得到了分配器

'字符串'具有错误的类型(预期的str,得到了spacy.tokens.doc.Doc)

如何修复 Python 错误:没有足够的值来解包(预期 2,得到 1)

我在 python3 中不断收到此错误“类型错误:需要一个整数(得到类型 str)”

无法在自托管 Azure VM 上运行 Python Selenium 测试

自托管代理上的Azure DevOps Python Pipeline Agent.ToolsDirectory错误

Python Azure图形:访问令牌丢失或格式错误

python azure函数中的错误404 HEAD依赖关系

pip安装上的Azure DevOps python feed错误