';语法错误:python3空闲中的无效语法 [英] 'SyntaxError: invalid syntax' in python 3 IDLE
本文介绍了';语法错误:python3空闲中的无效语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么这是语法错误?我该如何修复它?
class Queue:
#Queue is basicliy a List:
def __init__(self):
self.queue = []
#add to the top of the list (the left side)
def Enqueue(self, num):
if isinstance(num, int):
self.queue.append(num)
#remove from the top of the list and return it to user
def Dequeue(self):
return self.queue.pop(0)
#this function gets inputs from user, and adds them to queue,
#until it gets 0.
def addToQueue(queue, num):
num = input()
while num != 0:
queue.Enqueue(num)
num = input()
推荐答案
交互模式(带有>>>
提示符)一次仅接受一条语句。您输入了两个要一次处理的条目。
输入类定义后,确保添加一个额外的空行,以便交互提示符知道您已经完成。一旦出现>>>
提示,您将知道它已准备好进行函数定义。
您的其余代码看起来都很好。快乐计算:-)
这篇关于';语法错误:python3空闲中的无效语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文