Python代码未运行输入(可能与菜单相关)

Python代码未运行输入(可能与菜单相关),python,attributeerror,Python,Attributeerror,在我的最后一个问题中,我收到了菜单上的帮助,菜单现在正在运行!但是,当我输入半径时,我收到了错误: AttributeError:部分初始化的模块“圆”没有属性“区域”,这很可能是由于循环导入导致的。将circle.area更改为area,并将circle.圆周更改为圆周。将面积函数和周长函数的定义移到顶部,以便在使用之前对其进行定义。最后干掉主线。阅读而不是键入你不懂的魔法咒语,并希望它们能以某种方式发挥作用:我对你的代码做了一些更改,它应该能按预期工作。如果你有任何问题,请告诉我 基本上,删

在我的最后一个问题中,我收到了菜单上的帮助,菜单现在正在运行!但是,当我输入半径时,我收到了错误:


AttributeError:部分初始化的模块“圆”没有属性“区域”,这很可能是由于循环导入导致的。将circle.area更改为area,并将circle.圆周更改为圆周。将面积函数和周长函数的定义移到顶部,以便在使用之前对其进行定义。最后干掉主线。阅读而不是键入你不懂的魔法咒语,并希望它们能以某种方式发挥作用:

我对你的代码做了一些更改,它应该能按预期工作。如果你有任何问题,请告诉我

基本上,删除导入,删除主要功能,并将面积和周长移到顶部

import circle
pi = 3.1415

def main():

        area(radius)
        circumference(radius)

def menu():
        
        print("Type a for area of circle")
        print("Type b for circumference of a circle")
        print("Type c to END PROGRAM")     
loop=True

while loop:
        menu()
        choice = input('Please enter your choice: ')

        if choice== "a":
                radius = float(input ("Input the radius of the circle : "))
                print(circle.area(radius))
        elif choice== "b":
                radius = float(input ("Input the radius of the circle : "))
                print(circle.circumference(radius))
        else:
                print("Goodbye!")
                

def area(radius):
    return pi * radius**2


def circumference(radius):
    return 2 * pi * radius

main()

你能分享模块圈的代码吗?或者是当前正在执行的文件?无法导入正在运行的同一文件。请提供所需的[最小、可复制的示例]。在您发布MCVE代码并准确指定问题之前,我们无法有效地帮助您。我们应该能够将您发布的代码粘贴到文本文件中,并重现您指定的问题。谢谢!我为这件事绞尽脑汁已有一个小时了
pi = 3.1415

# function to print the menu options
def menu():
    print("Type a for area of   ")
    print("Type b for circumference of a circle")
    print("Type c to END PROGRAM")

# function to calculate area
def area(radius):
    return pi * radius**2

# function to calculate circumference
def circumference(radius):
    return 2 * pi * radius

# menu loop
while True:

    # display menu
    menu()

    # prompt for user's choice
    choice = input('Please enter your choice: ')

    if choice == "a":
        radius = float(input("Input the radius of the circle : "))
        print(area(radius))
    elif choice == "b":
        radius = float(input("Input the radius of the circle : "))
        print(circumference(radius))
    else:
        print("Goodbye!")
        break