python - 无法在 Python 中输入(file.xml)
问题描述
我想通过 cmd 输入文件名。所以我用
file1=input("File Scan1: ")
但是当我输入文件名链接 File1.xml 时,Python 告诉我:
Traceback (most recent call last):
File "compare.py", line 6, in <module>
file1=input("File Scan1: ")
File "<string>", line 1, in <module>
AttributeError: type object 'file' has no attribute 'xml'```
How can i solve this?
解决方案
这是我的代码。它正在比较 2 次 nmap 扫描并确定实际上未使用的 mac 地址
from xml.dom import minidom
print("Compare 2 Nmap Mac Scans /n")
file1=input("File Scan1: ")
file2=input("File Scan2: ")
xmldoc1=minidom.parse(file1)
hosts=xmldoc1.getElementsByTagName('host')
xmldoc2=minidom.parse(file2)
maclist1=[]
maclist2=[]
for host in hosts:
adress=host.getElementsByTagName("address")
if len(adress) > 1:
mac=adress[1].attributes["addr"]
MAC=mac.value
maclist1.append(MAC)
hosts=xmldoc2.getElementsByTagName('host')
for host in hosts:
adress=host.getElementsByTagName("address")
if len(adress) > 1:
mac=adress[1].attributes["addr"]
MAC=mac.value
maclist2.append(MAC)
for i in maclist1:
for j in maclist2:
if(i!=j):
print(i)
推荐阅读
- android - 如何知道登录的是哪种类型的 FirebaseUser?
- dart - 我有两个数字列表。如何从这些列表中生成随机数,而不在同一天重复相同的组合
- java - 按 JPA 规范排序
- node.js - 对 MongoDB 的工作原理感到困惑
- python - Python 只读取字典中的最后一项?
- java - 无法使用 Spring Cloud Feign 从 Postman Echo 服务获得响应
- javascript - 如何读取使用输入并检查输入的 url 是否来自 youtube.com
- excel - 搜索日期行并返回列字母时出错
- mysql - MySQL左连接 - 定义/访问别名列
- rust - Why does fmt::Arguments as_str not work when arguments are passed?