Skip to content

Instantly share code, notes, and snippets.

@Congee
Created February 23, 2015 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Congee/f439e1de1ca7c8b95076 to your computer and use it in GitHub Desktop.
Save Congee/f439e1de1ca7c8b95076 to your computer and use it in GitHub Desktop.
支持拼音首字母检索
#!/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