摘要:
1 ''' 2 正则表达式是字符串处理的有力工具和技术,正则表达式使用预定义的特定模式去匹配一类具有共同特征的字符串, 3 主要用于字符串处理,可以快速、准确地完成复杂的查找、替换等处理要求。 4 正则表达式由元字符及其不同组合来构成,通过巧妙地构造正则表达式可以匹配任意字符串,并完成复杂的字符串处理任务。 5 ''' 6 ''' 7 如果以'\'开头的元字符与转义字符相同,则需要... 阅读全文
posted @ 2017-06-08 21:15
JustLittle
阅读(913)
评论(0)
推荐(0)
摘要:
1 import jieba #导入jieba模块 2 x = '分词的准确度直接影响了后续文本处理和挖掘算法的最终效果。' 3 jieba.cut(x) #使用默认词库进行分词 4 print(list(jieba.cut(x))) 5 # ['分词', '的', '准确度', '直接', '影响', '了', '后续', '文本处理', '和', '挖掘', '算法',... 阅读全文
posted @ 2017-06-08 17:14
JustLittle
阅读(4170)
评论(0)
推荐(0)
摘要:
1 #coding=utf-8 2 import random 3 import string 4 import codecs 5 ''' 6 演示如何使用Python标准库random来生成随机数据,这在需要 7 ''' 8 #常用汉字Unicode编码表 9 StringBase = '\u7684\u4e00\u4e86\u662f\u6211\u4e0... 阅读全文
posted @ 2017-06-08 16:11
JustLittle
阅读(4692)
评论(0)
推荐(0)
摘要:
1 def crypt(source,key): 2 from itertools import cycle 3 result='' 4 temp=cycle(key) 5 for ch in source: 6 result=result+chr(ord(ch)^ord(next(temp))) 7 return resul... 阅读全文
posted @ 2017-06-08 14:08
JustLittle
阅读(8294)
评论(0)
推荐(0)
摘要:
1 import textwrap 2 doc='''Beautiful is better than ugly. 3 Explicit is better than implicit. 4 Simple is better than complex. 5 complex is better than complicated. 6 Flat is better than dense.... 阅读全文
posted @ 2017-06-08 13:54
JustLittle
阅读(1822)
评论(0)
推荐(0)
摘要:
1 ''' 2 center()、ljust()、rjust(),返回指定宽度的新字符串,原字符串居中、左对齐或右对齐出现在新字符串中, 3 如果指定宽度大于字符串长度,则使用指定的字符(默认为空格进行填充)。 4 ''' 5 print('Hello world!'.center(20)) #居中对齐,以空格进行填充 6 # Hello world! ... 阅读全文
posted @ 2017-06-08 10:54
JustLittle
阅读(5768)
评论(0)
推荐(0)

浙公网安备 33010602011771号