Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/286.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
Python 我想知道我怎样才能使这项工作成功_Python - Fatal编程技术网

Python 我想知道我怎样才能使这项工作成功

Python 我想知道我怎样才能使这项工作成功,python,Python,我得到了一个错误:“很高兴认识你,威尔!你出生在哪里?”? 佛罗里达州 回溯(最近一次呼叫最后一次): 文件“C:/Users/39.cr/PycharmProjects/untitled/test.py”,第3行,在 出生=输入(“”) 文件“”,第1行,在 NameError:未定义名称“Florida” 您还需要使用原始输入(“”)来获取出生地名,因为您使用的是Python 2。在Python3上,您的代码可以工作。原因是在Python 2中,您需要使用raw_input()来获取字符串,

我得到了一个错误:“很高兴认识你,威尔!你出生在哪里?”? 佛罗里达州 回溯(最近一次呼叫最后一次): 文件“C:/Users/39.cr/PycharmProjects/untitled/test.py”,第3行,在 出生=输入(“”) 文件“”,第1行,在 NameError:未定义名称“Florida”

您还需要使用原始输入(“”)来获取出生地名,因为您使用的是Python 2。在Python3上,您的代码可以工作。原因是在Python 2中,您需要使用raw_input()来获取字符串,而不是其他对象类型。

尝试以下方法:

name = raw_input("Hello sir! What is your name?")
print ("Nice to meet you " + name + "! Where were you born?")
born = input(" ")
print ("So your name is " + name + " and you were born in " + born + "!")

在python 2中,在这两种情况下,
input
都应该是
raw\u input
name = raw_input("Hello sir! What is your name?")
born = raw_input("Nice to meet you " + name + "! Where were you born?")
print("So your name is " + name + " and you were born in " + born + "!")