有人可以帮我解决python上的语法错误

时间:2017-07-20 05:31:55

标签: python python-3.x

请帮我解释这段代码,因为我尝试过很多不同的东西而无法使用它。谢谢你的帮助。

print(" Greenfly Population Model")
chocies=[]


def option0():
    time.sleep(1)
    print("GOOD BYE")
    time.sleep(1)
    # exiting the loop

def option1():
    if choies==[]:
        print("Set the Generation 0 values!")
    else:
        print(chocies[:])
def option2():
    print("Display the Generation 0 values")


def option3():
    print("Run the model")

def option4():
    print("Export data")

def option5():
    print("Quit")





import time#for option 0
while True:#to keep the program continuous
    option=int(input("""
    High Scores


0- Exit
1- Show score
2- Add a score
3- Delete a score
4 - Sort the score in ascending order
5- Sort the score in descending order
""")#all different options


s = int(input("from the menu above please pick your choice"))
print("setting the generation 0 values"))
i = int(input("Enter the number of generations you want the model to run for (must be between 5 and 25 inclusive")):
m = int(input("Choose adult survival rate between 0 and 1:"))
o = int(input("Choose Juvenile survival rate between 0 and 1:"))
n = int(input("Choose Senile survival rate between 0 and 1:"))
r = int(input("please enter the initial numbers of juvenile:"))
a = int(input("please enter the initial numbers of adults:"))
i = int(input("please enter the initial numbers of seniles:"))
v = int(input("please enter the initial numbers of the adults:"))

print(s)
print(i)
print(m)
print(o)
print(n)
print(r)
print(a)
print(i)
print(v)



print(" Greenfly Population Model")
option=int(input("""
High Scores


0- Exit
1- Show score
2- Add a score
3- Delete a score
4 - Sort the score in ascending order
5 - Sort the score in descending order
""")#all different options

我的语法错误是

s = int(input("from the menu above please pick your choice"))

s是我的语法错误

2 个答案:

答案 0 :(得分:2)

你有几个问题(从头到尾):

  1. 最后遗失) ... """)#all different options - > """))#all different options
  2. :不应该i = int(input("Enter the number of generations you want the model to run for (must be between 5 and 25 inclusive")):
  3. )不应该print("setting the generation 0 values"))
  4. 与第48行中的1相同
  5. 在发生此类错误后检查匹配括号等非常有用:)

    修正版:

    print(" Greenfly Population Model")
    chocies=[]
    
    
    def option0():
        time.sleep(1)
        print("GOOD BYE")
        time.sleep(1)
        # exiting the loop
    
    def option1():
        if choies==[]:
            print("Set the Generation 0 values!")
        else:
            print(chocies[:])
    def option2():
        print("Display the Generation 0 values")
    
    
    def option3():
        print("Run the model")
    
    def option4():
        print("Export data")
    
    def option5():
        print("Quit")
    
    
    
    
    
    import time#for option 0
    while True:#to keep the program continuous
        option=int(input("""
        High Scores
    
    
    0- Exit
    1- Show score
    2- Add a score
    3- Delete a score
    4 - Sort the score in ascending order
    5- Sort the score in descending order
    """))#all different options
    
    
    s = int(input("from the menu above please pick your choice"))
    print("setting the generation 0 values")
    i = int(input("Enter the number of generations you want the model to run for (must be between 5 and 25 inclusive"))
    m = int(input("Choose adult survival rate between 0 and 1:"))
    o = int(input("Choose Juvenile survival rate between 0 and 1:"))
    n = int(input("Choose Senile survival rate between 0 and 1:"))
    r = int(input("please enter the initial numbers of juvenile:"))
    a = int(input("please enter the initial numbers of adults:"))
    i = int(input("please enter the initial numbers of seniles:"))
    v = int(input("please enter the initial numbers of the adults:"))
    
    print(s)
    print(i)
    print(m)
    print(o)
    print(n)
    print(r)
    print(a)
    print(i)
    print(v)
    
    
    
    print(" Greenfly Population Model")
    option=int(input("""
    High Scores
    
    
    0- Exit
    1- Show score
    2- Add a score
    3- Delete a score
    4 - Sort the score in ascending order
    5 - Sort the score in descending order
    """))#all different options
    

答案 1 :(得分:0)

这是我到目前为止所做的事情

print(" Greenfly Population Model")

chocies=[]


def option0():
    time.sleep(1)
    print("GOOD BYE")
    time.sleep(1)
    # exiting the loop

def option1():
    if chocies==[]:
        print("Set the Generation 0 values!")
    else:
        print(chocies[:])
def option2():
    print("Display the Generation 0 values")


def option3():
    print("Run the model")

def option4():
    print("Export data")

def option5():
    print("Quit")





import time#for option 0
while True:#to keep the program continuous
    option=int(input("""

("""
print(" Greenfly Population Model")
chocies=[]


def option0():
    time.sleep(1)
    print("GOOD BYE")
    time.sleep(1)
    # exiting the loop

def option1():
    if choies==[]:
        print("Set the Generation 0 values!")
    else:
        print(chocies[:])
def option2():
    print("Display the Generation 0 values")


def option3():
    print("Run the model")

def option4():
    print("Export data")

def option5():
    print("Quit")


    High Scores

("""
0- Exit
1- Show score
2- Add a score
3- Delete a score
4 - Sort the score in ascending order
5- Sort the score in descending order
""")#all different options


s = int(input("from the menu above please pick your choice"))
print("setting the generation 0 values"))
i = int(input("Enter the number of generations you want the model to run for (must be between 5 and 25 inclusive")):
m = int(input("Choose adult survival rate between 0 and 1:"))
o = int(input("Choose Juvenile survival rate between 0 and 1:"))
n = int(input("Choose Senile survival rate between 0 and 1:"))
r = int(input("please enter the initial numbers of juvenile:"))
a = int(input("please enter the initial numbers of adults:"))
i = int(input("please enter the initial numbers of seniles:"))
v = int(input("please enter the initial numbers of the adults:"))

print(s)
print(i)
print(m)
print(o)
print(n)
print(r)
print(a)
print(i)
print(v)


("""
print(" Greenfly Population Model")
option=int(input
High Scores


0- Exit
1- Show score
2- Add a score
3- Delete a score
4 - Sort the score in ascending order
5 - Sort the score in descending order
#all different options


""")


import time#for option 0
while True:#to keep the program continuous
    option=int(input("""
    High Scores


0- Exit
1- Show score
2- Add a score
3- Delete a score
4 - Sort the score in ascending order
5- Sort the score in descending order
"""))#all different options


s = int(input("from the menu above please pick your choice"))
print("setting the generation 0 values")
i = int(input("Enter the number of generations you want the model to run for (must be between 5 and 25 inclusive"))
m = int(input("Choose adult survival rate between 0 and 1:"))
o = int(input("Choose Juvenile survival rate between 0 and 1:"))
n = int(input("Choose Senile survival rate between 0 and 1:"))
r = int(input("please enter the initial numbers of juvenile:"))
a = int(input("please enter the initial numbers of adults:"))
i = int(input("please enter the initial numbers of seniles:"))
v = int(input("please enter the initial numbers of the adults:"))

print(s)
print(i)
print(m)
print(o)
print(n)
print(r)
print(a)
print(i)
print(v)



print(" Greenfly Population Model")
option=int(input("""
High Scores


0- Exit
1- Show score
2- Add a score
3- Delete a score
4 - Sort the score in ascending order
5 - Sort the score in descending order
"""))#all different options