import requests,time,json,datetime def gettoken(): r=requests.get('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx4d75244c1b980b5b&secret=edf7d23a457fb4df5ad47eeb9d4b7a39').text token=json.loads(r)['access_token'] with open('D:/safesite/safesite/token.txt','w') as f: f.write(token) while True: gettoken() print('微信token读取----'+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")) time.sleep(600)