为什么从另一个文件调用函数时会出现此错误?

2024-09-30 08:25:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要帮助。我有一个主文件,还有一个名为main_func.py的文件,位于名为functions的文件夹中,该文件夹位于名为resources的文件夹中。它以前有用,但现在不行了。这是代码

from Resources.functions import main_func
....

def Main():
    conversionprocess()
    ....

然后在主函数文件中我有这个

def conversionprocess():
    Clear()
    print(cyan, 'The available units include miles, kilometers, meters, millimeters, centimeters, 
    inches, yards, and feet.\n\n')
    whattoconvert = input('What unit would you like to convert? PLEASE ANSWER WITH NO CAPITAL 
    LETTERS!:\n')
    ....

但它提出了一个错误:

NameError: name 'conversionprocess' is not defined

有人能帮我吗?? 谢谢大家!


Tags: 文件函数代码frompyimport文件夹main

热门问题