无故空投错误

2024-10-06 12:20:30 发布

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

好吧,我完全被一些超基本的python代码难住了。我觉得自己是个蠢货,不得不问这个问题,但这就是问题所在。我试图建立一个基本的端口扫描仪。我使用的代码,我绝对用过,并已工作。然而,每次我的代码运行时,我的空闲者都会抛出错误。你知道吗

我的代码段

##Request ip address and first port
web_request=urllib2.urlopen("http://" + ip + ":" + list(islice(port, 1))

##Define variable site as reading the webpage/ip address data
server=web_request.read()

##Show not open if length of site data is less than or equal to 1
if len(server)<='1':
    print ip + ":" + list(islice(port, 1)) + " Not open"

等等等等等等

当它到达“server=web_请求读取()“IDLE给我一个无效的语法错误,说“server”是问题所在。我试着把服务器改成其他关键字(如IP、网站、站点),但没有用。知道为什么idle不接受我的代码吗?你知道吗


Tags: 端口代码ipwebdataifserverport
1条回答
网友
1楼 · 发布于 2024-10-06 12:20:30

你的web_request有三个圆括号,只有两个右括号。你知道吗

# open:                    1                           2      3
web_request=urllib2.urlopen("http://" + ip + ":" + list(islice(port, 1))
# close:                                                              12

这几乎可以肯定是问题的起因,因为它认为server行是一个延续。你知道吗

相关问题 更多 >