第十一课 模块

一、日志记录模块

1.日志运行5个级别  debug  info warning error critical

2.默认打印是warning以上级别

怎么设置 打印级别 logging.basicConfig(level=logging.DEBUG)

3.常用的日志格式

第十一课 模块

4.自定义日志

第十一课 模块

二、OS模块

1.课堂小结

第十一课 模块

2.OS模块常用方法

第十一课 模块

第十一课 模块

3.sys模块

a.常用的命令

第十一课 模块

b.标准输出

#!/usr/bin/env python35
import sys
f = open('log.txt','a')   #以追加的模式打开一个文件
__console__ = sys.stdout   #备份默认console命令行
sys.stdout = f   #指定标准输出到文件
print('hello python')
sys.stdout = __console__  #将标准输出改为模式的console命令行模式
print('hello world')    #输出将会在console命令行下


[[email protected] python]# python35 stdout.py 
hello world
[[email protected] python]# cat log.txt 
hello python

c.标准输入

#!/usr/bin/env python35
 
import sys
name = sys.stdin.readline()  #接受标准输入,等价于raw_input()
print('输出:',name) 

4.random模块

第十一课 模块

第十一课 模块

5.课程实例

第十一课 模块