【问题标题】:Write french characters in python 2.7在 python 2.7 中编写法语字符
【发布时间】:2018-05-29 09:29:57
【问题描述】:

我正在尝试像这样在 python 2.7 中编写法语字符:

plt.xlabel("Débit")

但是,我遇到了这个错误:

ValueError: matplotlib display text must have all code points < 128 or use Unicode strings

请问有解决办法吗?

【问题讨论】:

  • plt.xlabel(u"Débit")?
  • 非常感谢。
  • 我将其添加为@Joe 问题的答案
  • 添加为 .py 文件的第一行:# coding: utf-8
  • @Mika72 仅声明源文件的编码,因此如果使用该声明,OP 应确保 save 以 UTF-8 格式保存文件。

标签: python python-2.7 matplotlib unicode


【解决方案1】:

错误ValueError: matplotlib display text must have all code points &lt; 128 or use Unicode strings 告诉你使用unicode 字符串,所以:

plt.xlabel(u"Débit")

【讨论】:

    猜你喜欢
    • 2017-03-29
    • 1970-01-01
    • 1970-01-01
    • 2013-08-30
    • 2016-12-15
    • 1970-01-01
    • 2015-04-23
    • 2014-09-10
    • 2014-05-09
    相关资源
    最近更新 更多