This is concerning Python: I’m trying to figure out how to read a file line by line, separate all content on any side of an “=“ sign, and store each object in the list (of each line) into separate variables which are stored in an instance of a class: I.e. 1+3 = 4*1 = 6-2
would be a: “1+3”, b: “4*1”, c: “6-2” inside of the class dVoc. Here is what I tried, however, it seems to just be reading and printing the file as is:
import getVoc
class dVoc:
def __init__(self, a, b):
self.a = a
self.b = b
def splitVoc():
with open("d1.md","r") as d1r:
outfile = open(f,'r')
data = d1r.readlines()
out_file.close()
def_ab = [line.split("=") for line in data]
def_ab
dVoc.a = def_ab[0]
dVoc.b = def_ab[-1]
print(dVoc.a)