【发布时间】:2021-06-08 13:55:14
【问题描述】:
我有一个txt文件写成
a,b,c,d,e ...
如何在 python 中阅读并重新排列如下格式?
a
b
c
d
e
非常感谢..
【问题讨论】:
我有一个txt文件写成
a,b,c,d,e ...
如何在 python 中阅读并重新排列如下格式?
a
b
c
d
e
非常感谢..
【问题讨论】:
如果你只是想转置你可以使用:
pd.read_csv('<Name of your csv file here>', header= None).T.to_csv('test.txt', index =False, header =None)
【讨论】:
>>> pd.Series(open("dummy.txt").read().rstrip().split(','))
0 a
1 b
2 c
3 d
4 e
dtype: object
【讨论】: