首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

python 日记分析

2012-09-04 
python 日志分析第一次学习python 准备做一个大型日志文件分析的case:1.分包,目录如下:logParser|--modul|

python 日志分析

第一次学习python 准备做一个大型日志文件分析的case:

1.分包,目录如下:

     logParser

           |--modul

                   |--FuncImple.py

           |--parser.py

2.分别建立文件,parser.py作为项目入口文件(主文件),module中作文子文件。要想在主文件中引用module包中的文件,必须在module包下建立一个名为__init__.py的空文件。

  现在的目录结构如下:

     logParser

           |--modul

                   |--FuncImple.py

                   |--__init__.py

           |--parser.py

3.FuncImple文件初定为:

    

class Func:    def __init__(self, name):        self.name = name    def getEffectiveAccess(self):        print "The effective access today is:"    def getAllIp(self):        print "All ip accessed the website is:"    def getEachUrlAccessed(self):        print "Each Url Accessed is:"    def getAccessesDuringTime(self ,start ,end):        print "The accesses during  is:"    def getOneUrlAccessedDuringTime(self, url, start, end):        print "The Url accessed during is:"


3.引入外部文件方式:

    在parser.py文件中加入如下语句

      from modul.FuncImple import Func

   到此为止,在主文件中就可以new一个Func对象,使用该对象中的成员和方法了。



热点排行