中英文混合,词数如何统计? ::-- ZoomQuiet [2007-05-08 02:39:44]

CPUG联盟::

CPUG::门户plone

BPUG

SPUG

ZPUG

SpreadPython Python宣传

1. batfree.混合字串统计

CPyUG:26258- 中英文混合,词数如何统计?

   1 import re
   2 cjkReg = re.compile(u'[\u1100-\uFFFDh]+?')
   3 trimedCJK = cjkReg.sub( ' a ', inputString, 0)# replace the CJK with the word a
   4 return  len(trimedCJK.split())

1.1. 反馈

MicroProj/2007-05-08 (last edited 2009-12-25 07:10:03 by localhost)