Python format()函数
在运行过程中发生以下错误!错在哪里Python format()函数,python,format,Python,Format,在运行过程中发生以下错误!错在哪里 class name: def create(self): person=input("Enter your name") print('hello {}'.format(person)) o=name() o、 创建() 输入您的姓名 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 o、 创建() 文件“”,第3行,在“创建”中 person=输入(“输入您的姓名”) 文件“”,第1行,在 NameError:
class name:
def create(self):
person=input("Enter your name")
print('hello {}'.format(person))
o=name()
o、 创建()
输入您的姓名
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
o、 创建()
文件“”,第3行,在“创建”中
person=输入(“输入您的姓名”)
文件“”,第1行,在
NameError:未定义名称“shubham”
我猜您使用的版本低于Python 3.x,所以
您必须在这里使用raw\u input()
,因为input()
试图解释您的提要
您可以找到解释。您正在使用python 2吗?如果您刚刚开始学习python,我建议您转到python 3。
o=name()
o.create()
Enter your nameshubham
Traceback (most recent call last):
File "<pyshell#53>", line 1, in <module>
o.create()
File "<pyshell#51>", line 3, in create
person=input("Enter your name")
File "<string>", line 1, in <module>
NameError: name 'shubham' is not defined