Python 名称错误:名称';代币';未定义microsoftgraph.client
我似乎无法在下面的代码中设置Python 名称错误:名称';代币';未定义microsoftgraph.client,python,microsoft-graph-api,Python,Microsoft Graph Api,我似乎无法在下面的代码中设置token。有人知道我在这里遗漏了什么吗 Python代码: from microsoftgraph.client import Client client = Client('client_id', 'client_pass', account_type='by defect common', office365=True) token = client.set_token(token) me = client.get_me() events = client.
token
。有人知道我在这里遗漏了什么吗
Python代码:
from microsoftgraph.client import Client
client = Client('client_id', 'client_pass', account_type='by defect common', office365=True)
token = client.set_token(token)
me = client.get_me()
events = client.get_me_events()
print(events)
print(me)
token = client.set_token(token)
NameError: name 'token' is not defined
结果:
from microsoftgraph.client import Client
client = Client('client_id', 'client_pass', account_type='by defect common', office365=True)
token = client.set_token(token)
me = client.get_me()
events = client.get_me_events()
print(events)
print(me)
token = client.set_token(token)
NameError: name 'token' is not defined
token=client.set\u令牌(token)
首先计算赋值的右侧<代码>令牌未在代码中的任何其他位置定义,因此它是一个未定义的名称。您在
令牌=客户端之前未初始化令牌
。设置令牌(令牌)
,因此,解释器无法识别括号内的标记
。如何初始化标记
?标记
只是代码内的任意变量。您需要从某个地方获取令牌,这取决于您的代码的功能。