这段代码是错误在哪里呢?
#定义的教师类模块
class Teather(object):
''' 教师类 '''
def __init__(self, t_name, t_number, phone):
'''
教师的基本信息
:param name: 教师姓名
:param t_number: 教师编号
:param phone: 教师的电话号码
'''
self.t_name = t_name
self.t_number = t_number
self.phone = phone
def __str__(self):
return 'name:{},t_number:{}'.format(self.t_name, self.t_number)
#教师信息初始化及运用
import Teather
def create_teacher():
''' 教师信息初始化 '''
dict_teacher = {"T1":["T1", "张亮", "13301122001"], "T2":["T2", "王朋", "13301122002"],
"T3":["T3", "李旭", "13301122003"], "T4":["T4", "黄国发", "13301122004"],
"T5":["T5", "周勤", "13301122005"], "T6":["T6", "谢富顺", "13301122006"],
"T7":["T7", "贾教师", "13301122007"], "T8":["T8", "杨教师", "13301122008"]}
list_teacher = []
for k in dict_teacher:
t = Teather(*dict_teacher[k])
print(t)
list_teacher.append(t)
print(list_teacher)
return list_teacher
#运行结果:
if __name__ == '__main__':
# list_ct = course_to_teacher()
# print(list_ct)
# list_s = create_student()
l = create_teacher()
name:T1,t_number:张亮
[<homework.project_homework.example.Teather object at 0x007E9050>]
name:T2,t_number:王朋
[<homework.project_homework.example.Teather object at 0x007E9050>, <homework.project_homework.example.Teather object at 0x00823650>]
name:T3,t_number:李旭
[<homework.project_homework.example.Teather object at 0x007E9050>, <homework.project_homework.example.Teather object at 0x00823650>, <homework.project_homework.example.Teather object at 0x008238F0>]
name:T4,t_number:黄国发
[<homework.project_homework.example.Teather object at 0x007E9050>, <homework.project_homework.example.Teather object at 0x00823650>, <homework.project_homework.example.Teather object at 0x008238F0>, <homework.project_homework.example.Teather object at 0x00823950>]
name:T5,t_number:周勤
[<homework.project_homework.example.Teather object at 0x007E9050>, <homework.project_homework.example.Teather object at 0x00823650>, <homework.project_homework.example.Teather object at 0x008238F0>, <homework.project_homework.example.Teather object at 0x00823950>, <homework.project_homework.example.Teather object at 0x00823970>]
name:T6,t_number:谢富顺
[<homework.project_homework.example.Teather object at 0x007E9050>, <homework.project_homework.example.Teather object at 0x00823650>, <homework.project_homework.example.Teather object at 0x008238F0>, <homework.project_homework.example.Teather object at 0x00823950>, <homework.project_homework.example.Teather object at 0x00823970>, <homework.project_homework.example.Teather object at 0x008239D0>]
name:T7,t_number:贾教师
[<homework.project_homework.example.Teather object at 0x007E9050>, <homework.project_homework.example.Teather object at 0x00823650>, <homework.project_homework.example.Teather object at 0x008238F0>, <homework.project_homework.example.Teather object at 0x00823950>, <homework.project_homework.example.Teather object at 0x00823970>, <homework.project_homework.example.Teather object at 0x008239D0>, <homework.project_homework.example.Teather object at 0x00823990>]
name:T8,t_number:杨教师
[<homework.project_homework.example.Teather object at 0x007E9050>, <homework.project_homework.example.Teather object at 0x00823650>, <homework.project_homework.example.Teather object at 0x008238F0>, <homework.project_homework.example.Teather object at 0x00823950>, <homework.project_homework.example.Teather object at 0x00823970>, <homework.project_homework.example.Teather object at 0x008239D0>, <homework.project_homework.example.Teather object at 0x00823990>, <homework.project_homework.example.Teather object at 0x008239F0>]
为什么得不到相关信息的列表呢?是哪里出错了,老师帮忙看看
正在回答 回答被采纳积分+1
相似问题
登录后可查看更多问答,登录/注册
- 参与学习 人
- 提交作业 2727 份
- 解答问题 8160 个
想要进入Python Web、爬虫、人工智能等高薪领域,你需要掌握本阶段的Python基础知识,课程安排带你高效学习轻松入门,学完你也能听得懂Python工程师的行业梗。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星