未在python中定义名称错误 [英] name error not defined in python

查看:172
本文介绍了未在python中定义名称错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是基本的字符串(在您想知道之前,文本是匈牙利语的):

So this is the basic string (the text is in hungarian before you are wondering):

>>> nev=input("add meg a neved: ")
add meg a neved: Kristóf
>>> print("Üdvözöllek, " + nev)
Üdvözöllek, Kristóf
>>> print("egy út előtt állsz")
egy út előtt állsz
>>> print("elindulsz rajta")
elindulsz rajta
>>> arany: 0
>>> print("Most" + str(arany)+ "aranyad van")
Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    print("Most" + str(arany)+ "aranyad van")
NameError: name 'arany' is not defined

该错误消息声称,即使我在IDE中为它提供了一个值,该名称也未定义,而我只是无法弄清楚我到底写错了什么...

The error message claims that the name is not defined, even though I gave it a value in the IDE, and I just cannot figure out what exactly did i wrote wrong...

任何帮助将不胜感激

推荐答案

应该为arany = 0,而不是arany: 0-我不确定为什么它甚至有效.

It should be arany = 0, not arany: 0 - I'm not sure why that's even valid.

这篇关于未在python中定义名称错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆