Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 名称错误:名称';代币';未定义microsoftgraph.client_Python_Microsoft Graph Api - Fatal编程技术网

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)


首先计算赋值的右侧<代码>令牌未在代码中的任何其他位置定义,因此它是一个未定义的名称。

您在
令牌=客户端之前未初始化
令牌
。设置令牌(令牌)
,因此,解释器无法识别括号内的
标记
。如何初始化
标记
标记
只是代码内的任意变量。您需要从某个地方获取令牌,这取决于您的代码的功能。