2005年05月27日 星期五 10:09
多字节文字一定要用unicode处理,先遵守这一点,再去做其它的。
a = unicode ("随着信息技术的发展,计算机应用渗透到社会生活的各个领域,特 
别是在电子商务中的应用,使人们对信息的依赖程度越来越大,从而使信息安全技 
术显得格外重要。信息安全技术主要是研究计算机系统信息的机密性、完整性、可 
获取性和真实性,它的核心是加密技术。加密技术根据加密密钥与解密密钥是否相 
同可分为对称加密技术(单密钥加密技术)和非对称加密技术(公开密钥加密技 
术)。加个叹号!加个问号?试试句号加引号。“试试叹号加引号!”。“试试问号 
加引号?” 加点废话", "cp936")
expression = unicode ("。|!|?|。”|!”|?", "cp936")
import re
listSentence = re.split (expression, a)
for i in listSentence:
    print i
dimension wrote:
>python-chinese,您好!
>
>	比如要实现一个句子分割器,
>只有是“。!?”以及
>。”
>!”
>?”
>等几种情况结尾的句子都分割称单独的句子。
>
>我利用正则表达式
>expression = r"。|!|?|。”|!”|?”"
>
>listSentence = re.split(expression, sentence)
>
>但是这样情况下,就会把汉字中某些字分开称乱码,比如:
>
>假如
>
>str1 = "【幸福】的人是很少的。"
>
>这样一个字符串就会被分开,因为“福”的后一半“】”的前一半正好是a3a1是一个“!”。当然,类似的情况肯定还有。
>
>不知道怎么解决。
>
>        致
>礼!
> 				
>
>        dimension
>        dimension at hit.edu.cn
>          2005-05-27
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>python-chinese list
>python-chinese at lists.python.cn
>http://python.cn/mailman/listinfo/python-chinese
>  
>
2005年05月27日 星期五 10:25
Yes !! 整理到 http://wiki.woodpecker.org.cn/moin/UnicodeInPython 算是 http://wiki.woodpecker.org.cn/moin/PythonInUnicode 的补充 程序员现在必须懂得 uncode 因为: * It is one of the cornerstones of software internationalization. * 这是软件国际化的王道 * The Web is full of Unicode data. * Web 已经充满了 Unicode 的数据 * XML and HTML are based on Unicode. * XML 和 HTML 技术是基于 Unicode 的 * WinNT-based operating systems use Unicode for all string values internally. * WinNT 基础的技术都是 Unicode 来处理所有字串的 This article is a short course on Unicode programming. 本文指出了处理Unicode 的快速途径 Pythonic 式的! 哈哈哈!! 在 05-5-27,cpunion<cpunion at 263.net> 写道: > 多字节文字一定要用unicode处理,先遵守这一点,再去做其它的。 > > a = unicode ("随着信息技术的发展,计算机应用渗透到社会生活的各个领域,特 > 别是在电子商务中的应用,使人们对信息的依赖程度越来越大,从而使信息安全技 > 术显得格外重要。信息安全技术主要是研究计算机系统信息的机密性、完整性、可 > 获取性和真实性,它的核心是加密技术。加密技术根据加密密钥与解密密钥是否相 > 同可分为对称加密技术(单密钥加密技术)和非对称加密技术(公开密钥加密技 > 术)。加个叹号!加个问号?试试句号加引号。"试试叹号加引号!"。"试试问号 > 加引号?" 加点废话", "cp936") > > expression = unicode ("。|!|?|。"|!"|?", "cp936") > > import re > > listSentence = re.split (expression, a) > for i in listSentence: > print i > > > dimension wrote: > > >python-chinese,您好! > > > > 比如要实现一个句子分割器, > >只有是"。!?"以及 > >。" > >!" > >?" > >等几种情况结尾的句子都分割称单独的句子。 > > > >我利用正则表达式 > >expression = r"。|!|?|。"|!"|?"" > > > >listSentence = re.split(expression, sentence) > > > >但是这样情况下,就会把汉字中某些字分开称乱码,比如: > > > >假如 > > > >str1 = "【幸福】的人是很少的。" > > > >这样一个字符串就会被分开,因为"福"的后一半"】"的前一半正好是a3a1是一个"!"。当然,类似的情况肯定还有。 > > > >不知道怎么解决。 > > > > 致 > >礼! > > > > > > dimension > > dimension at hit.edu.cn > > 2005-05-27 > > > > > >------------------------------------------------------------------------ > > > >_______________________________________________ > >python-chinese list > >python-chinese at lists.python.cn > >http://python.cn/mailman/listinfo/python-chinese > > > > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > -- [Time is unimportant, only life important!]
Zeuux © 2025
京ICP备05028076号