Data formats: XML, INI, TOML and pickle · 10 / 15 Exercise Medium

Read an INI file

Objective

INI files store configuration in [section] sections with key = value pairs. The configparser module reads them and lets you give a default value.

Instructions

  • The file config.ini exists in the working folder. The first line has the number n of queries; each one is a line section key default_value.
  • Show the value of the key, or the default value if the section or the key does not exist.
Input
3
server host x
server port 0
db name sin
Output
localhost
8080
sin

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise