python3 读取配置文件 configparser

配置文件

[blablabla]
bla = blabla
...


[testing settings]
#Choose the model to test: best==epoch with min loss, last==last epoch
best_last = best
#number of full images for the test (max 20)
full_images_to_test = 20
#How many original-groundTruth-prediction images are visualized in each image
N_group_visual = 1
#Compute average in the prediction, improve results but require more patches to be predicted
average_mode = True
#Only if average_mode==True. Stride for patch extraction, lower value require more patches to be predicted
stride_height = 5
stride_width = 5
#if running with nohup
nohup = False
import configparser

#config file to read from
config = configparser.RawConfigParser()
config.read(r'./configuration.txt')

nohup = config.getboolean('testing settings', 'nohup')   #std output on log file?
stride_height  = config.get('testing settings', 'stride_height')
bla = config.get('blablabla', 'bla')

print(type(nohup),nohup)
print(type(stride_height),stride_height)
print(type(bla),bla)

 False
 5
 blabla

你可能感兴趣的:(编程语言)