我想从iniFile
中筛选一个字符串,并将其转换为名为iniConf
的dict:
iniFile ='''
conf = test.ini
\# conf = test2.ini
conf_type = single
\#conf_type = multi
'''
infilter = ['conf', 'conf_type'] # to use
exfilter = ['#', 'multi'] # to skip
过滤后,我想得到
iniConf = {'conf':'test.ini', 'conf_type':'single'}
在python中解析ini文件最健壮的方法是使用ConfigParser模块,因为这样您就不必处理所有角落的情况或手动解析。你知道吗
相关问题 更多 >
编程相关推荐