import configparser
class readini(object):
def init(self,node=None):
if node == None:
self.node = "element"
else:
self.node = node
self.cf = self.load_ini(filename)
def load_ini(self,filename):
self.cf = configparser.ConfigParser()
self.cf.read(filename)
return self.cf
def get_value(self,node,key):
data = self.cf.get(node,key)
return data
if name == ‘main’:
read_ini = readini()
read_ini.load_ini(“D:/python/Tools/config/localelement.ini”)
print(read_ini.get_value(‘elements’,‘username’)
报错
File “D:/python/raed——ini.py”, line 13, in load_ini
self.cf.read(filename)
File “D:\python\lib\configparser.py”, line 693, in read
for filename in filenames:
TypeError: ‘NoneType’ object is not iterable
ini文件
[elements]
username=id>register-btn