import rewith open('inp.txt', 'rt', encoding='utf-8') as f_inp: data = f_inp.read() ii = re.finditer(r"^(?P<name>[a-zA-Z0-9_\-.]+)\s*{(?P<value>[^}]*)^\s*}", data, flags=re.MULTILINE)out = {c.group('name') : c.group('value') for c in ii}print(out)
Standard input is empty
Standard output is empty
Traceback (most recent call last): File "./prog.py", line 2, in <module> with open('inp.txt', 'rt', encoding='utf-8') as f_inp: FileNotFoundError: [Errno 2] No such file or directory: 'inp.txt'
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!