Created
February 23, 2015 10:12
-
-
Save Congee/f439e1de1ca7c8b95076 to your computer and use it in GitHub Desktop.
支持拼音首字母检索
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
#!/usr/bin/env python3 | |
# encoding: utf-8 | |
import pinyin | |
import sys | |
import re | |
query = sys.argv[1] | |
pattern = re.compile(query) | |
for line in sys.stdin: | |
p = pinyin.get_initial(line).replace(' ', '') | |
if re.search(pattern, p): | |
print(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment