NameError: name 'Person' is not defined
时间: 2023-09-10 09:06:53 浏览: 217
It seems like you are trying to use a class or a variable called "Person" but it has not been defined in the current scope. This error can occur when you try to access a variable or class that has not been defined yet or has been defined in a different module or file.
To solve this error, you need to define the missing variable or class in the current scope or import it from the appropriate module or file.
For example, if you are trying to use a class named "Person", you can define it in the current file like this:
```
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
```
If the "Person" class is defined in a different file, you can import it like this:
```
from my_module import Person
```
Replace "my_module" with the name of the module or file where the "Person" class is defined.
阅读全文