forked from FanGeGo/xxxx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathio_helper.py
More file actions
34 lines (24 loc) · 747 Bytes
/
io_helper.py
File metadata and controls
34 lines (24 loc) · 747 Bytes
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pickle
import sys
def saveintopickle(obj, filename):
with open(filename, 'wb') as handle:
pickle.dump(obj, handle, protocol=pickle.HIGHEST_PROTOCOL)
print ("[Pickle]: save object into {}".format(filename))
return
def loadfrompickle(filename):
with open(filename, 'rb') as handle:
b = pickle.load(handle)
return b
#draw the process bar
def drawProgressBar(percent, barLen = 20):
sys.stdout.write("\r")
progress = ""
for i in range(barLen):
if i < int(barLen * percent):
progress += "="
else:
progress += " "
sys.stdout.write("[ %s ] %.2f%%" % (progress, percent * 100))
sys.stdout.flush()