【问题标题】:How i over come with name error in python [duplicate]我如何在python中出现名称错误[重复]
【发布时间】:2017-04-13 18:13:20
【问题描述】:

我编写了以下代码,但在运行期间它在“raw_input”中给出了名称错误,请帮助我摆脱这个

我的代码是:fname = raw_input('enter a file name: ') print (fname)

错误是=名称错误:名称'raw_input'未定义

【问题讨论】:

  • 您使用的是 Python 3,其中 raw_input 现在已更改为简单的 input
  • 看起来您使用的是 Python 3,而 raw_input 不存在。将其替换为 input 或切换回 Python 2。

标签: python file compiler-errors namespaces raw-input


【解决方案1】:

python 3+ 上的raw_input 现在只是input()

fname = input('Enter a file name: ')
print(fname)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-18
    • 1970-01-01
    • 2015-01-18
    • 1970-01-01
    相关资源
    最近更新 更多