-
Notifications
You must be signed in to change notification settings - Fork 36
/
toolkit.py
38 lines (33 loc) · 951 Bytes
/
toolkit.py
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
# -*-coding=utf-8-*-
#常用的工具集合
__author__ = 'Rocky'
import codecs,re
class Toolkit():
@staticmethod
def save2file( filename, content):
# 保存为文件
filename = filename + ".txt"
f = open(filename, 'a')
f.write(content)
f.close()
@staticmethod
def save2filecn( filename, content):
# 保存为文件
filename = filename + ".txt"
f = codecs.open(filename, 'a',encoding='utf-8')
f.write(content)
f.close()
@staticmethod
def getUserData(cfg_file):
f=open(cfg_file,'r')
account={}
for i in f.readlines():
ctype,passwd=i.split('=')
#print ctype
#print passwd
account[ctype.strip()]=passwd.strip()
return account
@staticmethod
def filename_filter(filename_old):
filename = re.sub('[\/:*?"<>|]', '-', filename_old)
return filename