##language:zh #pragma section-numbers on ''' 中英文混合,词数如何统计? ''' ::-- ZoomQuiet [<>] <> ## 默许导航,请保留 <> = batfree.混合字串统计 = [[http://groups.google.com/group/python-cn/t/76703597d06173de|CPyUG:26258- 中英文混合,词数如何统计?]] {{{#!python import re cjkReg = re.compile(u'[\u1100-\uFFFDh]+?') trimedCJK = cjkReg.sub( ' a ', inputString, 0)# replace the CJK with the word a return len(trimedCJK.split()) }}} * 做过一部分测试,与Word里面的字数统计数目一样,不过不知道是不是还有问题。 == 反馈 ==