# -*- coding:utf-8 -*-
import os
import configparser
import codecs
import json
proDir = os.path.split(os.path.realpath(__file__))[0]
configPath = os.path.join(proDir, "config.ini")
class ReadConfig:
def __init__(self):
fd = open(configPath)
data = fd.read()
# remove BOM
if data[:3] == codecs.BOM_UTF8:
data = data[3:]
file = codecs.open(configPath, "w")
file.write(data)
file.close()
fd.close()
self.cf = configparser.ConfigParser()
self.cf.read(configPath)
def get_http(self,name):
value = self.cf.get('HTTP',name)
return value
def get_database(self,name):
value = self.cf.get('DATABASE',name)
return value
if __name__ == '__main__':
x = ReadConfig()
y = x.get_cookie()
#y = x.get_http('weburl')
print(y)
转载于:https://www.cnblogs.com/thcnww/p/8650606.html