2700c 短信 临时保存
2012-05-25 17:54
134 查看
# -*- coding: utf-8 -*- class MyMsg: "It's used to save the 2700c msg" phonePath = "c:/phone.txt" msgPath = "c:/msg.txt" outPath = "c:/" phones = {} @staticmethod def parsePhone(): f = open(MyMsg.phonePath, "r") for line in f.readlines(): c = line[0:-1].split("\t") MyMsg.phones[c[1]] = c[0] #delete the last '\n' f.close() @staticmethod def checkNum(n): if(n.startswith("+86")): n = n[3:len(n)] if(n.startswith("12520")): n = n[5:len(n)] return n @staticmethod def parseMsg(): MyMsg.parsePhone() f = open(MyMsg.msgPath, "r") file = open(MyMsg.outPath + "out.txt", "w") fno = open(MyMsg.outPath + "who.txt", "w") line = f.readline() while line: lens = len(line) while line and line[-2] != "\"": nline = f.readline() line = line[0:-1] + ' ' line += nline else: if line == 0: break tp = line[7:11] if tp == "READ": tp = "RECE" else: tp = "SEND" s = line.find("\"", 7, lens) s = line.find("\"", s+1, lens) num = None if tp == "RECE": e = line.find("\"", s+1, lens) num = line[s+1 : e] s = e+1 for z in range(5): s = line.find("\"", s+1, lens) e = line.find("\"", s+1, lens) else: s = line.find("\"", s+1, lens) s = line.find("\"", s+1, lens) e = line.find("\"", s+1, lens) num = line[s+1 : e] s = e+1 for z in range(3): s = line.find("\"", s+1, lens) e = line.find("\"", s+1, lens) tm = line[s+1 : e] s = e+1 for z in range(3): s = line.find("\"", s+1, lens) con = line[s+1 : -2] n = MyMsg.checkNum(num) if n in MyMsg.phones: n = MyMsg.phones file.write(tp) file.write('|' + n + '|' + tm + '|') file.write(con) file.write('\n') else: fno.write(tp) fno.write('|' + n + '|' + tm + '|') fno.write(con) fno.write('\n') line = f.readline() f.close() file.close() fno.close() print "瑙f瀽瀹屾瘯锛? MyMsg.parseMsg() ##f = open("c:/msg.txt", "r"); ## ##a = [line for line in f.readlines()] ## ##i = a[0] ##print i, len(i) ##ca = i.rfind("\"") ##cb = i.rfind("\"", 0, ca) ##print ca, cb, i[cb+1:ca] ##print i[7:11] == "READ" ##sa = -1 ##for k in range(5): ## sa = i.find("\"", sa+1, len(i)) ##sa += 1 ##sb = i.find("\"", sa, len(i)) ##print i[sa : sb] ##for k in range(5): ## sb = i.find("\"", sb+1, len(i)) ##sa = sb+1 ##print i[sa: i.find("\"", sa, len(i))] ##
相关文章推荐
- Git Stash保存临时修改用法
- 39. 腾讯面试题:有一千万条短信,有重复,以文本文件的形式保存,一行一条,有重复。
- 手机内保存了一年以上的两条短信
- [Android新手学习笔记08]-如何让活动Activity保存临时数据用于恢复
- 临时保存资料
- Android SMS(二)—— 读取短信保存到 SQLite
- activity 临时数据保存和恢复
- c语言部分基础(临时保存)
- 高通android 7.0短信草稿保存流程
- 某强人手机里保存的49条牛B短信
- SQL中把函数执行返回的数据保存到临时表,并把值赋给变量,输出变量的值
- 使用GDAL的MEM内存文件保存临时文件
- Android 存储学习之保存系统短信到SD卡
- 安卓开发--临时保存状态
- android保存短信到sim卡代码
- 临时资料保存
- 使用Cache-Control: no-store头,禁止IE浏览器保存临时文件,保护机密信息
- Android编程之SMS读取短信并保存到SQLite的方法
- ios--数据的临时保存形式
- Android SMS(二)—— 读取短信保存到 SQLite