import os
class Student(object):
def init(self,name="",school="",grade=""):
if not name:
name =raw_input("what is the student's name?")
if not school:
school=raw_input("what is the student's school?")
if not grade:
grade =self.get_grade()
self.name=name
self.school=school
self.grade=grade
def get_grade(self):
while True:
grade=raw_input("What is the student's grade?"[K,1-5])
if grade .lower() not in ['k','1','2','3','4','5']:
print ("I'm sorry,but{} isn't valid.")
else:
return grade
def print_student(self):
print ("Name:{}".format(self.name))
print ("School:{}".format(self.school))
print ("Grade:{}".format(self.grade))
def print_roster(students):
print ("Student in the system:")
for student in students:
print ("*"*15)
student.print_student()
def main():
student1=Student(name="1",grade="1",school="2")
print_roster(students)
if name=="_main_":
main()
os .system("pause")
python编写后运行时无法输入就退出(代码如下)
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- 普通网友 2017-05-04 13:11关注
raw_input该为input
python3已经废弃raw_inpurt了本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报