Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.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 Spotify-删除创建的无值访问令牌_Python_Spotipy - Fatal编程技术网

Python Spotify-删除创建的无值访问令牌

Python Spotify-删除创建的无值访问令牌,python,spotipy,Python,Spotipy,我正在尝试删除使用None值生成的Spotify访问令牌,该令牌在我第二次连接尝试时中断 我从这里得到了这个片段-->,用于清除缓存的令牌: import os from json.decoder import JSONDecodeError scope = <whatever_youwant> try: token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirec

我正在尝试删除使用None值生成的Spotify访问令牌,该令牌在我第二次连接尝试时中断

我从这里得到了这个片段-->,用于清除缓存的令牌:

import os
from json.decoder import JSONDecodeError

scope = <whatever_youwant>
try:
    token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)
except (AttributeError, JSONDecodeError):
    os.remove(f".cache-{username}")
    token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)

我的代币缓存在哪里?如何将其删除以重新获得访问权限?

缓存应存储在根目录(python文件的执行位置)的文件中

它的名字是
.cache-{username}
。确保打开了隐藏文件,否则可能看不到它

os.remove(f".cache-{username}")