1111

 

import

 

 内置函数

 

 

str.split(‘分隔符’)  分割函数。返回一个list

str.repiace(‘被替换值’,‘替换值’)    替换函数

 

 

正则表达式

 

 

 

 

f

import re
a='abc'
print(re.findall(a,'asdasdsfdabcasde'))

#输出 :['abc']
b='top tip txp'
c=r't[oi]p'       #[]里是字符集,中间有a或者i,都满足条件
print(re.findall(c,b))
#输出  ['top', 'tip']

 

^ :就是前面什么都没有

b='top tip txp'
c=r'^top'       #行首以top开头的进行匹配
print(re.findall(c,b))

 

b='top tip txp'
c=r'^top\$'       #\是取消$特殊的含义
print(re.findall(c,b))

 

 

 

 

如果是r=r'[^010-\d{8}]'   就是取反

 

b='a sad werwerwe  abbbbb'
c=r'ab*'       #a进行匹配 如果有b,以ab进行匹配
print(re.findall(c,b))

 

 

b='a sad werwerwe  abbbbb'
c=r'ab+'       #以ab进行匹配
print(re.findall(c,b))
#输出 ['abbbbb']

 

 

 

 

11111

posted on 2019-06-01 17:59  仙水阳  阅读(111)  评论(0)    收藏  举报