我创建了一个类,并试图将其值之一分配给需要字符串的对象,但它说它得到的是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
逗号使变量成为元组