2024-10-02 00:36:34 发布
网友
#ask user for input sInput = int(input("Enter the number of seconds. ") #calculations minutes = sInput / 60 minutes = int(minutes) totalHours = int(totalMinutes/60)
错误显示为:
分钟=输入/60
^
语法错误:无效语法
这是你的错误:
#ask user for input sInput = int(input("Enter the number of seconds. ")
你误用了右括号。 更正为:
#ask user for input sInput = int(input("Enter the number of seconds. "))
你在前一行忘了一个)!你知道吗
)
sInput = int(input("Enter the number of seconds. ") ^ here!
Python解析器的有趣之处在于,当有未闭合的圆括号或大括号时,它将扩展逻辑行,直到所有这些都闭合。然后,该注释被忽略,它发现minutes之间没有任何运算符。因此会出现语法错误,就像您编写:
minutes
sInput = int(input("...") minutes = sInput / 60 minutes = ... ^ syntax error!
这是你的错误:
你误用了右括号。 更正为:
你在前一行忘了一个
)
!你知道吗Python解析器的有趣之处在于,当有未闭合的圆括号或大括号时,它将扩展逻辑行,直到所有这些都闭合。然后,该注释被忽略,它发现
minutes
之间没有任何运算符。因此会出现语法错误,就像您编写:相关问题 更多 >
编程相关推荐