Kas*_*mad 6 scapy importerror visual-studio nameerror python-2.7
我有一个名为 handshake.py 的文件。哪里有函数send_data(argument)。我想将该函数导入另一个名为 siptest.py 的文件。我遇到两个问题。我在 64 位 Windows 7 上使用 microsoft Visual Studio。1)我无法导入功能。我试过使用,
from handshake import*
handshkae.send_data(argument)
Run Code Online (Sandbox Code Playgroud)
这给了我一个错误。
NameError: global name 'handshake' is not defined
Run Code Online (Sandbox Code Playgroud)
我尝试过的另一个选择是使用
import handshake
handshake.send_data(argument)
Run Code Online (Sandbox Code Playgroud)
这给了我一个属性错误。
AttributeError: 'module' object has no attribute 'send_data'
Run Code Online (Sandbox Code Playgroud)
如果我以其他方式使用它,例如
from handshake import send_data
Run Code Online (Sandbox Code Playgroud)
2) MS Visual Studio 说。没有发现测试,请检查配置设置,但我仍然可以以某种方式运行测试。它说由于导入错误而导致测试失败。
ImportError: cannot import name send_data
Run Code Online (Sandbox Code Playgroud)
这两个文件都在同一目录中。此外,该函数是在handshake.py 中的“TCPhandshake”类中定义的
小智 3
确保两个文件位于同一目录中,然后尝试:
from handshake import send_data
Run Code Online (Sandbox Code Playgroud)
如果这不起作用,请尝试重命名handshake.py 文件。
| 归档时间: |
|
| 查看次数: |
28228 次 |
| 最近记录: |