gpt4 book ai didi

python - 问候程序

转载 作者:太空狗 更新时间:2023-10-29 22:07:09 27 4
gpt4 key购买 nike

<分区>

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

name = input("What is your name? ")
print(name)
print("Hello" name )

结果是

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

当我执行 if 语句时,我放了

name = input("What is your name? ")
if name == ("Caleb"):
print(" Hello Bud!")

结果是

  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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com