gpt4 book ai didi

python - 模块未找到错误: No module named 'script' but script actually exist and directory precise

转载 作者:行者123 更新时间:2023-12-01 08:16:33 26 4
gpt4 key购买 nike

我创建了一个Python脚本,但是当我从他们的文件夹导入脚本时,我得到了ModuleNotFoundError:没有名为“reconstructors”的模块,但脚本在那里

funtions/reconstructors.py
funtions/handlers.py

import reconstructors as resx
import handlers as hand

然后,当我调用脚本时,我在 sentenceform.py 中使用它们到另一个脚本,我得到

ModuleNotFoundError: No module named 'reconstructors'

然后如果删除重建器,我得到

ModuleNotFoundError: No module named 'handlers'

这是sentenceform.py

import reconstructors as resx
import handlers as hand

def storeNewWrd(datname, val):
import json_function as js
data= js.loadJsonData(datname)
find = hand.existInJsonData(dataname, val, 'words')
if find == False:
data['words'].append({val : val})
js.EditJsonData(data, datname)
return True
else:
return False

def like(arg, dic):
word1 = arg.split()
word2 = dic.split()
sol =0

for wd2 in word2:
for wd1 in word1:
if wd1 == wd2:
sol += 1
if sol/len(word2) * 100 > 97.0:
return True
else:
return False

# def ReConstructSentence(sentence):



def addWord(sentence):
import json_function as js
Wrds = sentence.split()
data = js.loadJsonData('data')
for i in range(len(Wrds)):
Wrds[i] = resx.removeNonWordCharacters(Wrds[i])
for datas in data['words']:
if like(datas, Wrds[i]) == True:
if hand.existInJsonData('data', Wrds[i], 'words'):
return False
else:
print(sentenceWrds[i])
# storeNewWrd(datname, val)
# return True`enter code here`

最佳答案

技巧是使用路径定义来指定文件夹以便于访问

import sys
# the mock-0.3.1 dir contains testcase.py, testutils.py & mock.py
sys.path.append('/home/davis/Desktop/lisa/SentForm/functions')
import reconstructors as resx
import json_function as js
import handlers as

关于python - 模块未找到错误: No module named 'script' but script actually exist and directory precise,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54956686/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com