This is a problem the way the config parser in Python 2 works. The key-value pairs are converted into a dictionary. This means each key must be unique.
If you have multiple keys, the "last value wins".
Trying your example in Python 3.5, gives this error message:
DuplicateOptionError: While reading from 'config.ini' [line 4]:
option 'key_1' in section 'main' already exists
So don't use the the same key multiple times.
Fortunately, there is a backport for Python 2. Just:
pip install configparser
This library brings the updated configparser
from Python 3.5 to Python 2.6-3.5.
Now, use like this:
from configparser import ConfigParser
This is what Wikipedia says about duplicates:
Duplicate names
Most implementations only support having one property with a given name in a section. The second occurrence of a property name may cause an abort, it may be ignored (and the value discarded), or it may override the first occurrence (with the first value discarded). Some programs use duplicate property names to implement multi-valued properties.
Interpretation of multiple section declarations with the same name also varies. In some implementations, duplicate sections simply merge their properties together, as if they occurred contiguously. Others may abort, or ignore some aspect of the INI file.