带tor和reddit“KeyError”的python

2024-10-02 22:28:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我在github上发现了以下代码:https://github.com/Abrand88/Reddit-Tor-proxy-voting-bot/blob/master/reddit_proxy_voting_bot.py

我知道这是一个机器人和潜在的恶意,但我认为它很酷。从教育的角度看,我如何让它发挥作用?:当我运行程序时,它输出“socket:”两次,然后给出错误“KeyError:'127.0.0.1'”

有什么想法吗?你知道吗


Tags: 代码pyhttpsgithubmastercombot机器人
1条回答
网友
1楼 · 发布于 2024-10-02 22:28:11

它正在使用字典,找不到本地主机的密钥。你知道吗

这可能导致错误中断:

ip_hash={}; # the dictionary is made

以及

ip_hash[ip] = 1; # the dictionary is incorrectly accessed

光是这一部分不是个好主意:

if ip in ip_hash:
    print " repeat " + ip;
else:
    ip_hash[ip] = 1;

相关问题 更多 >