Created
April 10, 2022 08:39
-
-
Save peterjpxie/2b77e820899cbd6f25f52e4f9b88cb8c to your computer and use it in GitHub Desktop.
ini_to_dict.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ini_to_dict(input): | |
"""Covert a ini file to a simple dict | |
""" | |
with open(input) as f: | |
content = f.read() | |
ret_dict = {} | |
for line in content.split("\n"): | |
if " = " in line: | |
key, value = line.split(" = ", maxsplit=1) | |
ret_dict[key] = value | |
return ret_dict |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment