本文应用Python调用微信小程序获取access_token接口进行获取申请凭据。为了便于操作,这边联合了Python自带的GUI库Tkinter。

import requestsimport tkinterdef GetAccessToken():    url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=你的APPID&secret=你的APPSECRET"    res = requests.get(url)    access_token = res.text    print('已取得:'+access_token)    # 写入JSON文件,缓存到本地JSON文件    with open('access_token.json','w',encoding='utf-8') as f:        f.write(access_token)        # GUI操作界面root = tkinter.Tk()root.geometry("500x300")root.title("TANKING")button = tkinter.Button(text="获取access_token",command=GetAccessToken)button.pack()button.mainloop()

Author:TANKING
Date:2021-8-1
WeChat:sansure2016