小编Kan*_*ter的帖子

如何在Python 3中创建包?ModuleNotFoundError

我按照Python Central上的简易指南为我的代码创建一个包:

https://www.pythoncentral.io/how-to-create-a-python-package/

所以我的目录结构是:

main.py
pack1/
         __init__.py
         Class1.py
Run Code Online (Sandbox Code Playgroud)

main.py我导入和使用的文件Class1中:

from pack1 import Class1
var1 = Class1()
Run Code Online (Sandbox Code Playgroud)

__init__.py我写的文件中:

import Class1 from Class1
Run Code Online (Sandbox Code Playgroud)

我完全按照指南,仍然得到错误:

ModuleNotFoundError: No module named 'Class1' (in __init__.py)
Run Code Online (Sandbox Code Playgroud)

python packages python-3.x

7
推荐指数
1
解决办法
4638
查看次数

javascript中切换大小写跳转到错误大小写(如何正确使用break命令)

我的代码不是很长,所以我把它全部粘贴在这里。

代码不完整,但是当我运行它时,它首先跳转到它应该的 case“start”,然后跳转到 case“end”。我可以看到它,因为它打印了两个块的控制台日志文本。为什么会跳到“结束”的情况下?

<html>
    <body>
        <script>
            function stepStream(stream,step){
                switch (stream[step]){
                    case "start":
                        console.log("Started reading stream...");
                    case "end":
                        var success = "Finished reading dataStream.";
                        console.log(success);
                        return success;
                    default:
                        throw "Data stream format is bad";                  
                    case "gesture":
                        console.log("Running case gesture! But why?");
                        step+=1;
                        stepStream(stream,step);
                    case "say":
                        step+=1;
                        stepStream(stream,step);
                    case "sleep":
                        step+=1;
                        stepStream(stream,step);
                }

            }

            var sentence1 = "Where are my bananas? I thought you put them in my bag?";
            var sentence2 = "This is a rather irritating situattion.";  
            var dataStream = …
Run Code Online (Sandbox Code Playgroud)

javascript switch-statement

3
推荐指数
1
解决办法
769
查看次数