当前位置:天才代写 > tutorial > Python教程 > python 分析日志

python 分析日志

2018-05-17 08:00 星期四 所属: Python教程 浏览:872

python">#!/bin/env python

import json
import time, datetime

stackP = open("./outLog")

for eachLine in stackP:
    result = eachLine.find("signalingDomain")
    if result == -1:
        continue
    stringStart = eachLine.find('{')
    stringEnd = eachLine.rfind('}')

    string = eachLine[stringStart:stringEnd + 1]

    jsonString = json.loads(string)
    sessionId = jsonString['commandHead']['sessionId']
    cCRequestType = jsonString['commandHead']['cCRequestType']
    cCRequestNumber = jsonString['commandHead']['cCRequestNumber']
    print sessionId, cCRequestType, cCRequestNumber

标签:python

 

    关键字:

天才代写-代写联系方式