Beispiel #1
0
def main():
    L = []
    while True:
        user_input = input("请选择:")
        if user_input == 'q':
            break
        elif user_input == '1':
            c.input_student(L)
        elif user_input == '2':
            c.print_student(L)
        elif user_input == '3':
            c.deL_student(L)
        elif user_input == '4':
            c.xiugai_student(L)
        elif user_input == '5':
            c.student_score5(L)  #升序
        elif user_input == '6':
            c.student_score6(L)  #降序
        elif user_input == '7':
            c.student_age1(L)  #升序
        elif user_input == '8':
            c.student_age2(L)  #降序
        elif user_input == '9':
            L = c.student_read()
        elif user_input == '10':
            c.student_write(L)
Beispiel #2
0
def main():
    #此列表用于保存学生数据
    infos = []
    while 1:
        menu.show_menu()
        s = input("请选择:")
        if s == "1":
            infos += si.input_student()
        elif s == "2":
            si.output_student(infos)
        elif s == "3":
            si.del_stu(infos)
        elif s == "4":
            si.modify_stu(infos)
        elif s == "5":
            si.student_score_sort_h_l(infos)
        elif s == "6":
            si.student_score_sort_l_h(infos)
        elif s == "7":
            si.student_age_sort_h_l(infos)
        elif s == "8":
            si.student_age_sort_l_h(infos)
        elif s == "9":
            infos = si.stu_read()
        elif s == "10":
            si.save_to_file(infos)
        elif s == "q":
            break
Beispiel #3
0
def main():
    global list
    while True:
        #打印菜单
        #show_menu()
        show_menu.menu()

        s = input('请选择:')
        if s == '1':
            list = student_info.input_student()
             
        elif s == '2':
            student_info.print_student(list)

        elif s == '3':
            student_info.delete_student()

        elif s =='4':
            student_info.modify_student()

        elif s == '5':
            student_info.max_min_score()
             
        elif s == '6':
            student_info.min_max_score()

        elif s == '7':
            student_info.max_min_age()

        elif s =='8':
            student_info.min_max_age()    
        
        elif s == "q":
            break
Beispiel #4
0
def main():
    infos=[]
    while True:
        m.output_menu()
        try:
            choice = input('请选择功能\n')
        except:
            print('输入有误')
            continue
        if choice== 'q':
            sys.exit()
        elif choice == '1':
            infos = si.input_student(infos)
        elif choice == '2':
            si.output_student(infos)
        elif choice == '3':
            infos = si.del_student_infos(infos)
        elif choice == '4':
            infos = si.modify_student_infos(infos)
        elif choice == '5':
            infos = si.sort_by_score_h2l(infos)
        elif choice == '6':
            infos = si.sort_by_score_l2h(infos)
        elif choice == '7':
            infos = si.sort_by_age_h2l(infos)
        elif choice == '8':
            infos = si.sort_by_age_l2h(infos)
        elif choice == '9':
            infos = si.get_info_from_file()
        elif choice == '10':
            si.save_info_to_file(infos)
Beispiel #5
0
def main():
    a="1"
    b="2"
    c ='3'
    d="4"
    f ="5"
    g="6"
    h="7"
    k="8"
    a1="9"
    a2="E"
    e='q'
    L=[]
    while True:
        x=input("请选择:")

        if x is a:
            L=L+student_info.input_student(L)
            print(L)
        elif x is b:
            student_info.output_student(L)
        elif x is c:
            student_info.delete_student(L)
        elif x is d:
            student_info.correct_student(L)
        elif x is f:
            L=sorted(L,key=student_info.cj,reverse=True)
            student_info.output_student(L)
        elif x is g:
            L=sorted(L,key=student_info.cj,reverse=False)
            student_info.output_student(L)
        elif x is h:
            L=sorted(L,key=student_info.nj,reverse=True)
            student_info.output_student(L)
        elif x is k:
            L=sorted(L,key=student_info.nj,reverse=False)
            student_info.output_student(L)
        elif x is a1:
            student_info.cun(L)
        elif x is a2:
            student_info.read(filename='si.txt')
            


        else:
            x is e
            break
Beispiel #6
0
def main():
    L = []
    while True:
        #打印菜单
        #show_menu()
        show_menu.menu()

        s = input('请选择:')
        if s == '1':
            L = student_info.input_student()
             
        elif s == '2':
            student_info.print_student(L)

        elif s == '3':
            student_info.delete_student(L)

        elif s =='4':
            student_info.modify_student(L)

        elif s == '5':
            student_info.max_min_score(L)
             
        elif s == '6':
            student_info.min_max_score(L)

        elif s == '7':
            student_info.max_min_age(L)

        elif s =='8':
            student_info.min_max_age(L)

        elif s == '9':
            L = student_info.student_read()

        elif s == '10':
            student_info.student_write(L)     
        
        elif s == "q":
            break
Beispiel #7
0
L = []


def save_infos(L, filename="sis.txt"):

    try:
        f = open(filename, "w")
        try:
            for d in L:
                f.write(d["姓名"])
                f.write(",")
                f.write(str(d["年龄"]))
                f.write(",")
                f.write(str(d["成绩"]))
                f.write("\n")
        finally:
            f.close()
    except OSError:
        print("打开文件失败")


def print_info(a):
    for d in a:
        print(d["姓名"], "今年", d["年龄"], "岁 成绩是:", d["成绩"])


IT = input_student(L)
print(IT)
save_infos(IT)
print_info(IT)
Beispiel #8
0
# 练习:
#    1. 写一个程序,输入很多人的姓名,年龄,成绩存于文件
#      'infos.txt'中
#      文件格式自己定义(建议用逗号(,)来分隔各信息)
#     完成输入后查看文件格式是不是您想要的格式
#     (用文本文件进行操作)

#     L = input_student()
#     def save_to_file(L, filename='infos.txt')
#         ..

#     save_to_file(L)

from student_info import input_student

L = input_student()
print(L)


def save_to_file(L, filename='info2.txt'):
    '''此函数用于把L中的信息存到filename文件中,
    格式为:
        张三,20,100
        李四,18,98
        小王,22,95
    '''
    try:
        f = open(filename, 'w')
        try:
            # 循环写入数据
            for d in L: