Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我不明白这是什么意思;语法错误:无效语法";用于Python 3中的此代码_Python_Python 3.x - Fatal编程技术网

我不明白这是什么意思;语法错误:无效语法";用于Python 3中的此代码

我不明白这是什么意思;语法错误:无效语法";用于Python 3中的此代码,python,python-3.x,Python,Python 3.x,错误显示为: 分钟=sInput/60 ^ 语法错误:无效语法您在前一行中忘记了一个) #ask user for input sInput = int(input("Enter the number of seconds. ") #calculations minutes = sInput / 60 minutes = int(minutes) totalHours = int(totalMinutes/60) Python解析器的有趣之处在于,当存在未闭合的括号或大括号时,它将扩展逻辑行

错误显示为:

分钟=sInput/60

^

语法错误:无效语法

您在前一行中忘记了一个

#ask user for input
sInput = int(input("Enter the number of seconds. ")

#calculations
minutes = sInput / 60
minutes = int(minutes)
totalHours = int(totalMinutes/60)
Python解析器的有趣之处在于,当存在未闭合的括号或大括号时,它将扩展逻辑行,直到所有这些都闭合。然后,该注释被忽略,它会发现
minutes
之间没有任何运算符。因此会出现语法错误,就像您编写:

sInput = int(input("Enter the number of seconds. ")
                                                   ^ here!
这是你的错误:

sInput = int(input("...") minutes = sInput / 60 minutes = ...
                          ^ syntax error!
你错用了一个结束括号。 将其更正为:

#ask user for input
sInput = int(input("Enter the number of seconds. ")

当您在一行开头看到sytax错误时,总是怀疑前一行有问题。我可以推荐一个带有语法突出显示的文本编辑器吗?这往往会使这类错误立即变得显而易见。
#ask user for input
sInput = int(input("Enter the number of seconds. "))