.Tang

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

json:

 

import json
user = {
'dsada': 'whichT','a':True,'b':None
}
a=json.dumps(user,indent=3,sort_keys=True,separators=(',',':'))
print(a)
>>>
{
"a":true,
"b":null,
"dsada":"whichT"
}
b=json.loads(a)
print(b)

>>> {'a': True, 'b': None, 'dsada': 'whichT'}

 

 

正则:

'''
非\n,开头,结尾,0-多次,1- ,0-1,次数{n,m},或, 转义,或, 分组
  .        ^           $         *          +        ?     {N,M}     [a,^]      \         |     ()                                        这些都是元字符
search     --> 只返回第一个值,or None
findall      --> [符合条件全部放进来],
match      --> 从首字母开始匹配 = ^
compile    --> 把正则表达式编译成正则对象
sub           --> 类似字符串替换 res=re.sub('o','i','python',1)      --> pythin
split          --> 能用正则方法切割 res=re.split('\d','ad87ada5ad4f5')      --> ['ad', '', 'ada', 'ad', 'f', '']

group,start ,end,span             # match对象时使用
[.,^]        . 是字符, ^取反

'''

import re

re.findall(r'\d+?','dasdafafaa31')               #  +: 1-   ?:取最小值 1次'

 

posted on 2017-12-18 10:49  .Tang  阅读(283)  评论(0编辑  收藏  举报