【问题标题】:unicode in python 3 gives NameError: global name 'unicode' is not definedpython 3中的unicode给出NameError:未定义全局名称'unicode'
【发布时间】:2013-10-29 17:28:48
【问题描述】:

我正在尝试在 Python 3 中运行包含以下行的脚本:

yield [unicode(cell, 'utf-8') for cell in row]

但是,我不断收到此错误: NameError: global name 'unicode' is not defined

我环顾四周,包括这里: How to make unicode string with python3

但建议的答案没有帮助。

有什么想法吗?

【问题讨论】:

  • 执行str(cell, 'utf-8')时引发的异常是什么?
  • TypeError: decoding str is not supported
  • 那么cell已经是一个Unicode字符串了。

标签: python unicode


【解决方案1】:

卸载 python 然后重新安装。 python中有损坏的包...

【讨论】:

    猜你喜欢
    • 2013-11-21
    • 2022-02-24
    • 2016-07-06
    • 2013-08-23
    • 1970-01-01
    • 2012-03-28
    • 2013-07-20
    相关资源
    最近更新 更多