forked from Lemonzhulixin/python-appium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasePickle.py
More file actions
53 lines (45 loc) · 1.16 KB
/
BasePickle.py
File metadata and controls
53 lines (45 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import pickle
import os
def write(data, path="data.pickle"):
with open(path, 'wb') as f:
pickle.dump(data, f, 0)
def read(path):
with open(path, 'rb') as f:
try:
data = pickle.load(f)
except EOFError:
data = {}
# print("读取文件错误")
# print("------read-------")
# print(data)
return data
def readInfo(path):
# data = []
with open(path, 'rb') as f:
try:
data = pickle.load(f)
print(data)
except EOFError:
data = []
# print("读取文件错误")
# print("------read-------")
# print(data)
return data
def writeInfo(data="", path="data.pickle"):
"""
:type data: dict
"""
_read = readInfo(path)
result = []
if _read:
_read.append(data)
result = _read
else:
result.append(data)
with open(path, 'wb') as f:
# print("------writeInfo-------")
# print(result)
pickle.dump(result, f)
if __name__ == "__main__":
# write("用例失败重连过一次,失败原因:", "../Log/connect64dd15b8-ca91-11e7-87ae-38c98647adce.pickle")
pass