一、复习

1.文件操作 

 import codecs

with codces.open("1.txt","r") as f:

f.truncate()  清空

f.write()  字符串

f.read()  返回值字符值

f.readlines 返回的是列表

f.readline 返回的是一行

f.seek 寻找,设置偏移量

f.tell 光标在哪里

pass

2.lambda函数

a=lambda x:  x*x    \\a代表函数

迭代器  [x for x in range(1,10) if x%2 ==0 ]

高阶函数 sorted() 可迭代对象,key  反转

3.return和yield区别

4.()跟[]区别 

装饰,列表生成式

5.两个List相加 +

  两个字典相加 update

6.类 class (类都是大写)

构造器 __init__(args)

装饰器 super(子类,self)

继承 A(B) \\A类继承于B

类的封装 a.实例化

               b.main()

               c.if__name__=='__main__':

__init__ 实例化时间需要执行

__name__ 

7.装饰器作用:在不改变函数情况下,对函数增加一些功能

8.常用模块

OS模块  os.mkdir

              os.path.exist ()是否存在文件

              os.linesep 换行

              os.system("ipconfig")  执行系统命令

json模块 json.loads()

              json.dumps()

              json.load()

 commands模块  Python2

 getstatusoutput \\返回结果值

sys模块

import sys

            sys.argv[1]  \\获取第一个参数

random模块

random.random()  0-1取值之间

random.randint(a,b)

random.sample(itertable,k)  验证码

string模块

               string.punctugtion 特殊字符

logging模块

              logger = logging.getlogger(__name__)

              logger.debug

hashlib模块

             m=hashlid.md5()

             src="abcd"

             m.update(bytes(src))

加密 m.hexdigest()

datetime模块

              from datetime import datetime

              datetime.now()

              datetime.year  month  day  hour minute  second

               datetime.now.strptime("%Y-%m-%d")   字符串转换成时间

time模块

              time.time()

               time.sleep(10)

StringIO  模块

              from  io import StringIO ,ByesIO

              s=StringIO()

              s.write("hello word")

              s.getvalue()

              s.truncate() 清空

二、正则

常用的网站  http://tool.oschina.net/regex 正则表达式

第十三课 复习 正则

1.re.match函数

第十三课 复习 正则

2.re.search方法

第十三课 复习 正则

第十三课 复习 正则

第十三课 复习 正则


第十三课 复习 正则


第十三课 复习 正则

第十三课 复习 正则

第十三课 复习 正则

第十三课 复习 正则

第十三课 复习 正则

第十三课 复习 正则


第十三课 复习 正则第十三课 复习 正则

第十三课 复习 正则

第十三课 复习 正则


相关文章: