我的文件结构如下:
if($("#YourTextAreaID").val().trim().length < 1)
{
alert("Please Enter Text...");
return;
}
/dir/
main.py
/src/
functionsfile.py
classfile.py
具有使用在functionsfile
中创建的类的函数。我用
classfile
(我也尝试导入from classfile import ClassName
)。
仅使用*
语句测试functionsfile
中的函数,它似乎找到了类模块并使用print
就好了,但是当我ClassName
从import
到functionsfile
脚本的函数,它给了我错误:
main.py
我尝试同时导入两个函数:
ModuleNotFoundError: No module named 'classfile'
和
from functionsfile import function
我不知道为什么会这样吗?
答案 0 :(得分:1)
似乎您缺少 __ init __。py 文件。将其添加到/ src /文件夹后,尝试导入。
答案 1 :(得分:1)
尝试
from src.classfile import ClassName
更改目录结构也将更好。
/dir
/src
/class
classfile.py
functionsfile.py
main.py
答案 2 :(得分:1)
就像水瓶座所说的那样,您需要在src文件夹中创建一个空白的Unrestricted
文件
并尝试将其导入为
Import-Module CosmosDB
$Guid = $([Guid]::NewGuid().ToString())
$document = @" { ... } "@
$cosmosDbContext = New-CosmosDbContext -Account $CosmosDbAccountName
-Database $DatabaseName -ResourceGroup $ResourceGroupName New-CosmosDbDocument -Context $cosmosDbContext -CollectionId $CollectionId -DocumentBody $document -PartitionKey "$Guid"
在您的__init__.py
文件中
我希望它对您有用:D