问题 1
- \u200b \u200c ... 这类零宽字符去除
- ascii 前面那堆去除
— –类似这种长得很像减号换成减号- 保留可见的 unicode 字符,包括中文、阿拉伯语、日文、西班牙语等字符。
类似这样的字符清洗的轮子有嘛? 手动写筛选条件怕有遗漏。
问题 2
另外在 python3 里,有些字符串
"\u2086san'中文"
类似这样的,其中中文也是 unicode,但是是可见的。
用 unicode-escape 的话,中文也会变成\u 开头。
有没有方法,在\u2086这种表现形式的字符出现的时候,判断一下?
4 条回复 • 2019-01-11 14:54:03 +08:00
|
1
locoz 2019 年 1 月 11 日
捞一下防沉
|
|
2
xpresslink 2019 年 1 月 11 日 form = ['NFC', 'NFKC', 'NFD', 'NFKD']
unicodedata.normalize(form[3], unicodestr) |
|
3
JCZ2MkKb5S8ZX9pq OP @xpresslink 谢谢 我查一下
|
|
4
JCZ2MkKb5S8ZX9pq OP @xpresslink 好像并没有滤掉 `\u200b` 这类零宽字符
|
推荐学习书目
› 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