Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.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
应为:-将Eclipse与PyDev一起使用_Eclipse_Python 3.x - Fatal编程技术网

应为:-将Eclipse与PyDev一起使用

应为:-将Eclipse与PyDev一起使用,eclipse,python-3.x,Eclipse,Python 3.x,我刚刚启动了python的新版本,并意识到有很多变化。无论如何,eclipse在行号旁边有一个红色的“X”标记,上面写着“预期::”。有人能解释一下这意味着什么,我怎样才能摆脱它 这是我试图使用Eclipse和新的Python版本编写的代码: print "Please insert a valid operator that you want to calculate with." print "Valid operators are +, -, : and *" operator = s

我刚刚启动了python的新版本,并意识到有很多变化。无论如何,eclipse在行号旁边有一个红色的“X”标记,上面写着“预期::”。有人能解释一下这意味着什么,我怎样才能摆脱它

这是我试图使用Eclipse和新的Python版本编写的代码:

print "Please insert a valid operator that you want to calculate with."

print "Valid operators are +, -, : and *"

operator = str(raw_input("What's your operator? "))

numb1 = int(raw_input("Please insert the first number:"))
numb2 = int(raw_input("Please insert the second number:"))

if operator == "+":
print numb1 + numb2
elif operator == "*":
print numb1 + numb2
elif operator == "-":
print numb1 - numb2
elif operator == "/":
print numb1 / numb2

在Python3上,
print
是一个函数,而不是一个语句,因此应该编写它(例如)

另外,
raw_input
已重命名为
input
,因此它应该是(例如):


在Python3上,
print
是一个函数,而不是一个语句,因此应该编写它(例如)

另外,
raw_input
已重命名为
input
,因此它应该是(例如):


我运行了这个程序,当我在Eclipse上的Pydev上运行它时,我没有发现任何问题,即使我在2.7上运行它。也许这和你的缩进有关

operator = str(raw_input("What's your operator? "))

numb1 = int(raw_input("Please insert the first number:"))
numb2 = int(raw_input("Please insert the second number:"))

if operator == "+":
    print numb1 + numb2
elif operator == "*":
    print numb1 + numb2
elif operator == "-":
    print numb1 - numb2
elif operator == "/":
    print numb1 / numb2

我运行了这个程序,当我在Eclipse上的Pydev上运行它时,我没有发现任何问题,即使我在2.7上运行它。也许这和你的缩进有关

operator = str(raw_input("What's your operator? "))

numb1 = int(raw_input("Please insert the first number:"))
numb2 = int(raw_input("Please insert the second number:"))

if operator == "+":
    print numb1 + numb2
elif operator == "*":
    print numb1 + numb2
elif operator == "-":
    print numb1 - numb2
elif operator == "/":
    print numb1 / numb2

我也复制粘贴了您的示例,为了修复它,我只需要像StackXchangeT那样修复缩进

然而,我得到了
预期的::
错误,因为在声明末尾缺少整理
,例如:

class MyInvalidClass
这应该是:

class MyInvalidClass:

在类似的情况下,可能会出现这样的错误,需要
(只是猜测)。

我也复制粘贴了您的示例,为了修复它,我只需要像StackExchange一样修复缩进

然而,我得到了
预期的::
错误,因为在声明末尾缺少整理
,例如:

class MyInvalidClass
这应该是:

class MyInvalidClass:

也许你在类似的情况下也会遇到这样的错误,需要
(只是一个猜测)。

但我的实际问题是什么呢。我不使用eclipse,所以我不知道该消息应该说什么或是什么意思。我为你添加了eclipse标签,希望那里的人能看到并回答你。但我的实际问题是什么呢?我误解了你的问题。我不使用eclipse,所以我不知道该消息应该说什么或是什么意思。我为您添加了eclipse标签,希望那里的人能看到并回答您。