Skip to content

Tag: dictionary

asdict() inside .format() in a Python class

How can I use asdict() method inside .format() in oder to unpack the class attributes. So that instead of this: I could write something like this: Answer asdict should be called on an instance of a class – self, in this case. Additionally, you don’t need the dict’s keys, you need its values,…

turn a multiple line of txt file into a dictionary

I have a multiple line of text like: and I need a way to read the txt file, and turn it into a dictionary like this so i can use and get the result of match that ended in draw is there a way to achieve this? Answer I would suggest to use a .json file, this way: The parsing