Home > other >  Refer to the Python
Refer to the Python

Time:01-05

1 why do, come on

CodePudding user response:

The class Student:
Def __init__ (self, s_id=0, name="None", room_id=None, gender="None") :
Self. S_id=s_id
The self. The name=name
Self. Room_id=room_id
Self. Gender=gender

The class the Teacher:
Def __init__ (self, student_list) :
Self. Student_list=student_list

Def set_info (self, info_list) :
For the index, the student in enumerate (self student_list) :
Student. S_id=info_list [index] [" s_id "]
Student. Name=info_list [index] [" name "]
Student. Room_id=info_list [index] [" room_id "]
Student. Gender=info_list [index] [" gender "]


A=Student ()
B=Student ()

C=the Teacher ([a, b])
Info_list=[{" s_id: "1000," name ":" zhang ", "room_id" : None, "gender" : "male"},
{" s_id: "1001," name ":" fours "and" room_id ":" 5-10 ", "gender" : "female"}]
C.s. et_info (info_list)
  • Related