python - Python - 'No module named..' 使用 Visual Studio 便携版
问题描述
我正在使用 Visual Studio Portable 创建 TCP 模拟器 - 在执行代码时使用 client.py、state.py 和 server.py 会产生错误:ModuleNotFoundError: No module named 'State' - 任何人都可以帮忙吗?
这是存在错误的行 'from State import *'
这就是终端产生的:
Traceback(最近一次通话最后一次):文件“c:/Users/Chloe/Documents/Computer Science Uni Work/Final Year/Computer Networks/Coursework 2/New/client.py”,第 1 行,来自状态导入 * ModuleNotFoundError:没有名为“状态”的模块
以下是 state.py 中包含的内容
class State:
state = None #abstract class
CurrentContext = None
def __init__(self, Context):
self.CurrentContext.Context = Context
class StateContext:
stateIndex = 0
CurrentState = None
availableStates = []
def setState(self, newstate):
self.CurrentState = self.availableStates[newstate]
self.stateIndex = newstate
def getStateIndex(self):
return self.stateIndex
非常感谢
解决方案
推荐阅读
- html - 按钮不为移动设备调整大小
- javascript - 禁止在字符串中交换人员敏感信息
- r - 删除 NA 并仅填充 tableGrob 中包含数字的单元格
- reactjs - 类型检查 AgGridReact
- windows-10 - 如何在没有外部源的情况下修复winsxs文件夹?
- c# - 如何在 Unity 中制作组合计时器
- python - 如何使用 azure 函数在 azure blob 存储中编辑 *.csv 文件?
- django - Django - settings.py 中的“myapp”与“myapp.apps.myappConfig”
- python - 将触摸对象的轮廓查找为两个不同的轮廓
- javascript - 如何编写正确的 app.get()?(node.js / express / boby-parser)