一.复习 看下面一段代码,假如运行结果有问题,那么就需要在每一步计算时,打印一下结果 b = 1 c = 2 d = 3 a = b+c print(a) e = a + d print(e) 执行输出: 36 但是线上的程序,是不允许随便print的,这个时候,就需要用到logging模块 import logging logging.basicConfig(level=logging.DEBUG,filename = 'userinfo.log') b = 1 c = 2 d = 3 a =…
#!/usr/bin/python # Filename: cat.py import sys def readfile(filename): '''Print a file to the standard output.''' f = file(filename) while True: line = f.readline() if len(line) == 0: break print line, # notice comma f.close() # Script starts from h…
#!/usr/bin/python # Filename: cat.py import sys def readfile(filename): '''Print a file to the standard output.''' f = file(filename) while True: line = f.readline() if len(line) == 0: break print line, # notice comma f.close() # Script starts from h…
os与sys模块的官方解释如下: os: This module provides a portable way of using operating system dependent functionality. 这个模块提供了一种方便的使用操作系统函数的方法. sys: This module provides access to some variables used or maintained by the interpreter and to functions that intera…