首页 > 解决方案 > python代码在运行时不会打印任何东西

问题描述

我正在尝试制作一些东西,将我所有的不和谐用户令牌放入 tokens.txt,然后告诉我它们是否是有效的用户令牌。但是,它从不打印任何内容,只是退出。如果有人知道如何解决这个问题,请告诉我。

import requests
    
with open("tokens.txt","r+") as f:
    for line in f:
        token=line.strip("\n")
        headers = {'Content-Type': 'application/json', 'authorization': token}
        url = "https://discordapp.com/api/v6/users/@me/library"
        if r.status_code == 200:
            print(token+" is valid")
        else:
            print("invalid token found~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")

我已经尝试过几次

$ python3 tokenfilter.py
$ python3 tokenfilter.py
$ 

标签: pythonpython-3.x

解决方案


你不提出任何要求。您应该添加如下内容:

r = requests.get(url, headers=headers)

推荐阅读