win7用不了python_python WIN7无法正常执行

用来整理nmap输出结果的,放在win7 64 py2.7下无法执行,提示

对python不是很了解,希望大神可以帮忙看下

import xml.dom.minidom

import sys

import getopt

statstr=""

statstrlist=["open"]

infile=""

outfile=""

infileflag=0

outfileflag=0

statstrflag=0

isstatflag=0

helpflag=0

#chu li can shu

options,args = getopt.getopt(sys.argv[1:],"hni⭕s:",["help","in=","out=","stat"])

for name,value in options:

if name in ("-h","--help"):

print """

xxoo.py

-h,--help print this help

-i,--in read the nmap xml outfile

-o,--out out the result (default: xmlname+_done.txt)

-s,--stat splited by dot (example:open.filtered.close default:open)

-n no status info

"""

helpflag=1

if name in ("-i","--in"):

infile=value

infileflag=1

if name in ("-o","--out"):

outfile=value

outfileflag=1

if name in ("-s","--stat"):

statstrlist=value.split(".")

statflag=1

if name=="-n":

isstatflag=1

#chu li mo ren can canshu

if outfileflag==0:

outfile=infile+"_done.txt"

if statstrflag==0:

statstrlist=["open"]

if helpflag==1:

exit()

#chu li dom

file=open(outfile,"w+")

dom=xml.dom.minidom.parse(infile)

root=dom.documentElement

hostlist=root.getElementsByTagName("host")

for hostnode in hostlist:

for hostchild in hostnode.childNodes:

if hostchild.nodeName=="address":

ip=hostchild.getAttribute("addr")

if hostchild.nodeName=="ports":

for hostchildchild in hostchild.childNodes:

if hostchildchild.nodeName=="port":

for stat in statstrlist:

if hostchildchild.childNodes[0].getAttribute("state")==stat:

if isstatflag==0:

print ip+":"+hostchildchild.getAttribute("portid")+"(("+stat+"))"

file.write(ip+":"+hostchildchild.getAttribute("portid")+"(("+stat+"))"+"\n")

if isstatflag==1:

print ip+":"+hostchildchild.getAttribute("portid")

file.write(ip+":"+hostchildchild.getAttribute("portid")+"\n")

#if hostchildchild.childNodes[0].getAttribute("state")=="open":

#print ip+":"+hostchildchild.getAttribute("portid")+"((open))"

# file.write(ip+":"+hostchildchild.getAttribute("portid")+"((open))"+"\n")

#elif hostchildchild.childNodes[0].getAttribute("state")=="filtered":

# print ip+":"+hostchildchild.getAttribute("portid")+"((filtered))"

# file.write(ip+":"+hostchildchild.getAttribute("portid")+"((filtered))"+"\n")

file.close()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以按照以下步骤下载和安装PythonWin7系统上: 1. 首先,确保你的Win7系统已经安装了SP1补丁,因为Python3需要在Win7系统上安装SP1补丁才能正常运行。 2. 进入Python官方网站(https://www.python.org/downloads/)[2]。 3. 根据你的电脑系统选择合适的Python版本进行下载。如果你的系统是Win7,可以选择Python 3.8.10版本。 4. 下载完成后,运行下载的安装程序。 5. 在安装程序的界面上,务必勾选“Add Python 3.10 to PATH”选项。这样可以将Python的安装路径添加到系统路径中,以便在执行CMD命令时可以直接调用python.exe。 6. 完成勾选后,点击“Install Now”按钮开始安装Python。 7. 安装过程中,请耐心等待,直到安装完成。 8. 安装完成后,你可以在开始菜单中找到Python的安装文件夹,并打开IDLE(Python的集成开发环境)来编写和运行Python代码。 通过按照以上步骤,你就可以在Win7系统上成功下载和安装Python了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [win7python3.6安装配置方法图文教程](https://download.csdn.net/download/weixin_38627234/14012217)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [【python教程入门学习】Python教程第1篇:下载和安装Python](https://blog.csdn.net/zihong523/article/details/122969399)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值