= 10:c = "***"print(c.cente..._python人工智能全栈ai应用开发课">
赞
踩
[Python] 纯文本查看 复制代码def student():
for a in range(1, 8, 2):
x = "*" * a
print(x.center(9), x.center(10), x.center(10), x.center(9))
else:
for y in range(1, 4 + 1):
c = "*"
if 4 >= 10:
c = "***"
print(c.center(9), c.center(10), c.center(10), c.center(9))
print("^^^^^^^^^^^^^ System menu ^^^^^^^^^^^^^")
print("---------------------------------------")
print(" 1): Add Student information ")
print("---------------------------------------")
print(" 2): print Student information ")
print("---------------------------------------")
print(" 3): delete Student information ")
print("---------------------------------------")
print(" 4): revamp Student information ")
print("---------------------------------------")
print(" please input number 1~4 select ")
print("---------------------------------------")
print(" input :(Q)Exit procedure ")
print("---------------------------------------")
# 创建输出函数:perform完成
# 创建输入函数:input_student开始 封装信息输入
def input_student():
L = []
print("--------Student information enty--------")
while True:
name = input("please input name:")
if name == "":
q = input("operation succeed! return y / n :")
if q == "y":
break
else:
input_student()
age = input("please input age:")
score = input("please input score:")
d = {}
d = {"name": name, "age": age, "score": score}
print("+---------------+----------+----------+")
name = d["name"].center(15)
age = d["age"].center(10)
score = d["score"].center(10)
print('''|%s|%s|%s|''' % (name, age, score))
print("+---------------+----------+----------+")
print("-----Not input Enter be no revamp!-----")
L.append(d)
return L
# 创建输入函数:input_student完成
# 创建输出函数:output_student开始 封装列表打印
def output_student(lst):
print("-------Student information sheet-------")
print("+---------------+----------+----------+")
print("| Name | Age | Score |")
print("+---------------+----------+----------+")
for d in lst:
name = d["name"].center(15)
age = d["age"].center(10)
score = d["score"].center(10)
print('''|%s|%s|%s|''' % (name, age, score))
print("+---------------+----------+----------+")
q = input("operation succeed! return y / n :")
if q == "y":
pass
else:
output_student()
# 创建输出函数:output_student完成
# 创建输出函数:delete_student开始 封装删除信息
def delete_student(lst):
name = input("please input name delete:")
for x in lst:
if x["name"] == name:
print("+---------------+----------+----------+")
name = x["name"].center(15)
age = x["age"].center(10)
score = x["score"].center(10)
print('''|%s|%s|%s|''' % (name, age, score))
print("+---------------+----------+----------+")
delet = input("whether delete (y:yes/y:no):")
if delet == "y":
lst.remove(x)
q = input("operation succeed! return y / n :")
if q == "y":
pass
else:
delete_student()
# 创建输出函数:delete_student完成
# 创建输出函数:revamp_student()开始 封装更改信息
def revamp_student(lst):
name = input("please input name revamp:")
for x in lst:
if x["name"] == name:
print("+---------------+----------+----------+")
name = x["name"].center(15)
age = x["age"].center(10)
score = x["score"].center(10)
print('''|%s|%s|%s|''' % (name, age, score))
print("+---------------+----------+----------+")
print("-----not input Enter be no revamp!-----")
rage = input("please input age revamp:")
rscore = input("please input score revamp:")
if rage != "":
x["age"] = rage
if rscore != "":
x["score"] = rscore
print("+---------------+----------+----------+")
name = x["name"].center(15)
age = x["age"].center(10)
score = x["score"].center(10)
print('''|%s|%s|%s|''' % (name, age, score))
print("+---------------+----------+----------+")
print("-----------revamp perform!------------")
else:
print("None Error")
q = input("operation succeed! return y / n :")
if q == "y":
pass
else:
revamp_student()
# 创建输出函数:revamp_student()完成
# 创建输出函数:System_menu()开始 临时封装系统
def System_menu():
L = []
while True:
student()
select = input(" please input:")
if select == '1':
L += input_student()
elif select == '2':
output_student(L)
elif select == '3':
delete_student(L)
elif select == '4':
revamp_student(L)
elif select == 'q':
break
# 创建输出函数:System_menu()完成 临时封装系统
# 运行
System_menu()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。