I have a text file that I would like to transpose using Python.
For example, given the following file:
asdfg qwert
I would like the out
Maybe this is you wanted:
with open("/Users/wy/Desktop/wy.txt", "r") as cin: lines = cin.read() lineStr = lines.split('\n') with open("/Users/wy/Desktop/res.txt", "w") as cout: for ele in zip(*lineStr): cout.write(''.join(list(ele)) + '\n')