V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
wdg8106
V2EX  ›  Python

python 怎么过滤 emoji 表情符号呢

  •  
  •   wdg8106 · 2016-04-27 16:13:01 +08:00 · 11050 次点击
    这是一个创建于 2913 天前的主题,其中的信息可能已经有所发展或是发生改变。
    看一篇文章写的, emoji 的 区间为 \u1F601-\u1F64F ,
    然后我用正则表达式
    re.compile(u'[\uF601-\u1F64F]').sub(u'',name)
    进行过滤,并没有起到效果呢,请问大家遇到表情符号是怎么解决的呢
    2 条回复    2016-04-27 21:17:20 +08:00
    GPU
        1
    GPU  
       2016-04-27 16:21:29 +08:00   ❤️ 1
    try:
    # UCS-4
    Emoji = re.compile(u'[\U00010000-\U0010ffff]')
    except re.error:
    # UCS-2
    Emoji = re.compile(u'[\uD800-\uDBFF][\uDC00-\uDFFF]')
    name = Emoji.sub(u'\u25FD', name)

    By @sciooga
    Khlieb
        2
    Khlieb  
       2016-04-27 21:17:20 +08:00 via Android   ❤️ 1
    Emoji 其实不止一个区间
    https://en.wikipedia.org/wiki/Emoji
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3773 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 05:05 · PVG 13:05 · LAX 22:05 · JFK 01:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.