小编Kbo*_*998的帖子

问候计划

我一直在学习如何使用"Python绝对初学者指南"这本书编写Python程序.我遇到的问题是,使用eclipse-pydev它时不允许我使用该if语句.这是我写的代码......

name = input("What is your name? ")
print(name)
print("Hello" name )
Run Code Online (Sandbox Code Playgroud)

结果是

What is your name? caleb
Traceback (most recent call last):
  File "/Users/calebmatthias/Document/workspace/de.vogella.python.first/simpprogram.py", line 6, in <module>
    name = input("What is your name? ")
  File "/Users/calebmatthias/Desktop/eclipse 2/plugins/org.python.pydev_2.2.3.2011100616/PySrc/pydev_sitecustomize/sitecustomize.py", line 210, in input
    return eval(raw_input(prompt))
  File "<string>", line 1, in <module>
NameError: name 'caleb' is not defined
Run Code Online (Sandbox Code Playgroud)

当我if发言时,我说

name = input("What is your name? ")
if name == ("Caleb"):
    print(" Hello Bud!")
Run Code Online (Sandbox Code Playgroud)

结果是

  What …
Run Code Online (Sandbox Code Playgroud)

python eclipse if-statement pydev new-operator

6
推荐指数
2
解决办法
1万
查看次数

而函数python

你好是使用eclipse和pydev,我想知道为什么我的示例代码不会尝试使用while函数.

print("Welcome to the annoying program")
response = ""
while response != "Because.":
  response = input("why\n")

print("Oh,ok")
Run Code Online (Sandbox Code Playgroud)

输出如下:

Welcome to the annoying program
why
Because.
Traceback (most recent call last):
 File "/Users/calebmatthias/Document/workspace/de.vogella.python.first/simpprogram.py", l      ine 9, in <module>
   response = input("why\n")
File "/Users/calebmatthias/Desktop/eclipse     2/plugins/org.python.pydev_2.2.3.2011100616/PySrc/pydev_sitecustomize/sitecustomize.py", line 210, in input
return eval(raw_input(prompt))
File "<string>", line 1
Because.
       ^
SyntaxError: unexpected EOF while parsing
Run Code Online (Sandbox Code Playgroud)

python eclipse pydev while-loop

1
推荐指数
1
解决办法
370
查看次数

Python while循环不断重复

我在while循环中遇到了一些问题.我在eclipse上运行它,我输入了源代码:

a = raw_input("Mom im hungry!!!!!! FEED MEEEEE" )
while a != "Feed yourself":
    print("Thats gross")
Run Code Online (Sandbox Code Playgroud)

结果是当我输入错误的答案时,它会响应:

Thats gross 
thats gross 
Run Code Online (Sandbox Code Playgroud)

等等.

python variables while-loop

-1
推荐指数
1
解决办法
1016
查看次数