问题描述
我已经创建了一个类,并尝试将其值之一分配给需要字符串的内容,但是它却说它正在获取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
逗号使变量成为元组