Spotipy-设置CLIENT_ID和CLIENT_SECRET [英] Spotipy - set CLIENT_ID and CLIENT_SECRET
问题描述
我在哪里设置CLIENT_ID和CLIENT_SECRET,使其不存储在我的python脚本中? Spotipy文档说明了以下内容,但是我无法弄清楚需要输入这些环境变量的位置.我在哪里设置os.getenv?
Where do I go to set CLIENT_ID and CLIENT_SECRET so it's not stored in my python script? The Spotipy documentation says the following, but I can't figure out where I need to go to input these environment variables. Where do I set os.getenv?
if not client_id:
client_id = os.getenv('SPOTIPY_CLIENT_ID')
if not client_secret:
client_secret = os.getenv('SPOTIPY_CLIENT_SECRET')
if not client_id:
raise SpotifyOauthError('No client id')
if not client_secret:
raise SpotifyOauthError('No client secret')
推荐答案
在Windows上,您可以设置环境变量以打开cmd,使用cd C:\example\example
将目录更改为保存.py文件的目录,然后使用SET SPOTIPY_CLIENT_ID=clientIDhere
和SET SPOTIPY_CLIENT_SECRET=secretHere
设置变量.
On windows you can set your enviroment variables openning your cmd, change your directory to where your .py file is saved using cd C:\example\example
then use SET SPOTIPY_CLIENT_ID=clientIDhere
and SET SPOTIPY_CLIENT_SECRET=secretHere
to set your variables.
这篇关于Spotipy-设置CLIENT_ID和CLIENT_SECRET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!