查询错误,求指教
from time import sleepfrom random import randint
data = [{"ID":1000000001, "name":"None", "sex":"男", "address":"青海"}
{"ID":1929489285, "name":"False", "sex":"女", "address":"computer"}]
while True:
print(" ****************************************")
print(" 欢迎使用学生管理系统v1.0(后续有2.0)")
print(" 1.显示所有学生")
print(" 2.新建学生档案")
print(" 3.查询学生信息")
print(" 4.修改学生档案")
print(" 5.删除学生档案")
print(" 0.退出")
print(" ****************************************")
print()
def print_all():
for student in data:
print(student)
pass
pass
def someThing_put_in():
ID = randint(1000000000, 9999999999)
try:
if ID in data:
ID = randint(1000000000, 9999999999)
except:
print("调试错误!")
someName = input("输入姓名:")
someSex = input("输入性别:")
someAddress = input("输入地址:")
student = {"ID":ID, "name":someName, "sex":someSex, "address":someAddress}
data.append(student)
someThing = input("Enter the num:")
if someThing == "0":
break
elif someThing == "1":
print_all()
continue
elif someThing == "2":
print("好的")
print()
sleep(1)
someThing_put_in()
结果一直:
invalid syntax
咨询下什么原因? from time import sleep
from random import randint
data = [{"ID":1000000001, "name":"None", "sex":"男", "address":"青海"},
{"ID":1929489285, "name":"False", "sex":"女", "address":"computer"}]
while True:
print(" ****************************************")
print(" 欢迎使用学生管理系统v1.0(后续有2.0)")
print(" 1.显示所有学生")
print(" 2.新建学生档案")
print(" 3.查询学生信息")
print(" 4.修改学生档案")
print(" 5.删除学生档案")
print(" 0.退出")
print(" ****************************************")
print()
def print_all():
for student in data:
print(student)
pass
pass
def someThing_put_in():
ID = randint(1000000000, 9999999999)
try:
if ID in data:
ID = randint(1000000000, 9999999999)
except:
print("调试错误!")
someName = input("输入姓名:")
someSex = input("输入性别:")
someAddress = input("输入地址:")
student = {"ID":ID, "name":someName, "sex":someSex, "address":someAddress}
data.append(student)
someThing = input("Enter the num:")
if someThing == "0":
break
elif someThing == "1":
print_all()
continue
elif someThing == "2":
print("好的")
print()
sleep(1)
someThing_put_in()
qiuyouzhi 发表于 2020-6-6 21:29
咨询下您修改哪里了 绝壁是用了中文符号…… 靳子轩 发表于 2020-6-6 21:30
咨询下您修改哪里了
data那里少了个逗号 老八秘制 发表于 2020-6-6 21:33
绝壁是用了中文符号……
把发红的左花括号用英文输了一遍,还是:
invalid syntax @qiuyouzhi
{:10_256:} 靳子轩 发表于 2020-6-6 21:30
咨询下您修改哪里了
04行最后要逗号 本帖最后由 老兵hb 于 2020-6-7 07:30 编辑
data =[{"ID":1000000001, "name": "None", "sex": "男", "address": "青海"},
{"ID":1929489285, "name": "False", "sex": "女", "address": "computer"}]
少了个逗号 @老八秘制
看看这段代码
https://fishc.com.cn/thread-171540-1-1.html
(出处: 鱼C论坛)
看下亲
页:
[1]