Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def txt(file,n_righe):
- f = open(file)
- lines = f.readlines()
- l = []
- for line in lines:
- for c in line:
- l.append(ord(c))
- mat = []
- n_columns = len(l) // n_righe + len(l) % n_righe
- print(len(l))
- print(l)
- for i in range(n_righe):
- riga = []
- for j in range(n_columns):
- print(f"{n_columns}*{i} + {j} = {n_columns*i + j}")
- if n_columns*i + j >= len(l):
- riga.append(0)
- else:
- riga.append(l[j*(i+1)])
- mat.append(riga)
- print(mat)
- txt("text/test1.txt",2)
Advertisement
Add Comment
Please, Sign In to add comment