Skip to content

Instantly share code, notes, and snippets.

@peterjpxie
Created April 10, 2022 08:39
Show Gist options
  • Save peterjpxie/2b77e820899cbd6f25f52e4f9b88cb8c to your computer and use it in GitHub Desktop.
Save peterjpxie/2b77e820899cbd6f25f52e4f9b88cb8c to your computer and use it in GitHub Desktop.
ini_to_dict.py
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