【发布时间】:2019-05-07 01:20:45
【问题描述】:
我最近一直在使用数组,在我的练习程序中,由于某种原因,它不会停止抛出语法错误,而且我的 IDE 告诉我的所有内容都是出乎意料的。据我所知,一切都很好。我只是需要另一双眼睛。
我尝试从头开始重写并完全开始一个新文件。我什至卸载了python并重新安装了它。
import array as arr
employee_names = arr.array("u",[])
employee_hours = arr.array("u,",[])
employee_wage = arr.array("u",[])
input_employees = int(input("Type 1 if you want to start or 0 if you want to quit: ")
while input_employees == 1:
input_names = input("Type in the names of the employees: ")
employee_names.append(input_names)
input_employees = int(input("If you want to enter more press 1 or if you are done press 0: ")
if input_employees == 0:
break
print(employee_names)
else:
continue
但是当你运行它时,由于某种原因,你会在 while 语句中遇到语法错误。
【问题讨论】:
-
您忘记关闭前一行的括号。
-
您也没有在第二个
input上关闭括号。 -
@kindall 是对的,但是您忘记在两个
input语句上关闭括号。 -
谢谢大家。我发布后不久就意识到了这一点。感谢您的帮助。