【问题标题】:Python regex and accented Expression [duplicate]Python正则表达式和重音表达式[重复]
【发布时间】:2016-04-22 08:52:46
【问题描述】:

我的 Python RegEx 处理块在处理重音表达式时遇到问题。 当我运行我的代码时:

import re
title = ur"Titre : c'est pas gréable à Infos:"
print title
m = re.findall(":(.+?) Infos",title , re.UNICODE)
print unicode((m))

我有这个结果:

Titre : c'est pas gréable à Infos:
[u" c'est pas gr\xe9able \xe0"]

我需要能够在结果输出中保留重音表达。 感谢您的帮助

【问题讨论】:

  • 您只是看到同一个 unicode 字符串的两种不同表示形式,一种使用 unicode 字符,另一种使用 utf-8 编码。

标签: python regex python-2.7 unicode non-ascii-characters


【解决方案1】:

试试这个:

  print unicode((m), 'utf-8').encode('utf-8')

【讨论】:

  • 同样的问题依然存在
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-03-16
  • 1970-01-01
  • 2016-11-16
  • 2016-07-22
  • 2013-10-25
  • 1970-01-01
  • 2013-05-19
相关资源
最近更新 更多