[TOC]
1、python运维工程师
高阶函数
from numpy import *
a = array([1,23,4,324])
a+1
- imp1.py
- imp2.py
- imp3.py
[root@VM-0-3-centos ~]# cat imp1.py
def scr(x):
s = x**3
return s
[root@VM-0-3-centos ~]# cat imp2.py
from imp1 import scr
print(scr(3))
[root@VM-0-3-centos ~]# cat imp3.py
import imp1
print(imp1.scr(3))
[root@VM-0-3-centos ~]# cat zhengze.py
a ='1238912asd3'
import re
aa = re.match(r'123',a)
print(aa)
print(aa.group())
bb = re.search(r'8912',a)
print(bb)
print(bb.group())
a1 = '192.168.111.171.3689'
cc = re.findall(r'\d{1,2}.\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}',a1)
print(cc)
输出
<_sre.SRE_Match object; span=(0, 3), match='123'>
123
<_sre.SRE_Match object; span=(3, 7), match='8912'>
8912
['192.168.111.171']