forked from hcj5206/CnkiAndCqvipCrawler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HCJ_Buff_Control.py
44 lines (39 loc) · 1.15 KB
/
HCJ_Buff_Control.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
39
40
41
42
43
44
#!/usr/bin/env python
# -*- coding:utf-8 -*-
'''
time:20190426
author: HCJ
自写类
'''
import configparser as ConfigParser
import os
import time
def Write_buff(file_buff="Config.ini", settion="Cqvip", info=None, state=None):
config = ConfigParser.ConfigParser()
if info == "":
return
if os.path.exists(file_buff):
try:
config.read(file_buff,encoding='utf-8-sig')
config.set(settion, info, str(state))
config.write(open(file_buff, "w+", encoding='utf-8-sig'))
except:
print("jhha")
else:
pass
def Read_buff(file_buff="Config.ini", settion="info", info=None):
if os.path.exists(file_buff):
config = ConfigParser.ConfigParser()
config.read(file_buff, encoding='utf-8-sig')
if config.has_option(settion, info):
test_value = config.get(settion, info)
return test_value
else:
return ""
else:
print("Not exit %s"%file_buff)
return None
if __name__ == '__main__':
a=Read_buff(file_buff="./Config.ini",settion='Setting',info='Cnki_interval').replace(' ','')
print(a)
pass