class student:
def __init__(self,name, major, gpa, is_on_probation):
self.name = name
self.major = major
self.gpa = gpa
self.is_on_probation = is_on_probation
我保存了这段代码,然后打开了一个新文件并键入了这段代码
from student import student
student1 = student('jake','business',3.1,False)
print(student1.name)
我犯了这个错误
ModuleNotFoundError:没有名为“student”的模块
我处理了pip路径并将其粘贴到命令提示符中,然后添加到路径\pip install student中
我犯了这个错误
Could not find a version that satisfies the requirement student (from versions: none)
找不到学生的匹配分布
ps:我正在使用python IDLE
将类实现保留在
students.py
中,然后在其他文件(file1.py)中导入student
类:只需在同一文件夹中创建一个空的新文件
__init__.py
相关问题 更多 >
编程相关推荐