Last active
June 25, 2017 20:18
-
-
Save shunfan/5847732 to your computer and use it in GitHub Desktop.
Slugify Chinese
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
""" | |
Slugify for Chinese | |
没有优化多音字 | |
优化多音字的项目有: | |
https://github.com/jiedan/chinese_pinyin | |
""" | |
import re | |
import unidecode | |
def slugify(str): | |
return re.sub(r'\s+', '-', unidecode.unidecode(str).lower().strip()) | |
# Test | |
print slugify(u"测试") | |
# >>> ce-shi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment