如何使我的数据帧转换成.txt文件后完全相同

2024-09-29 23:32:04 发布

您现在位置:Python中文网/ 问答频道 /正文

在提取一些文本后,我将它们保存为dataframe,并将其保存为.txt文件,但格式不相同。如何使它们保持相同并删除引号

    Yoruba                                   Meaning
1   Adìẹ funfun kò mọ ara rẹ̀lágbà           Respect yourself
2   Ọbẹ̀ kìí gbé inú àgbà mì                 You should be able to keep secrets
3   À ń pe gbẹ́nàgbẹ́nà ẹyẹ àkókó ń yọjú      Never think too highly of yourself
4   Díẹ̀ díẹ̀ nimú ẹlẹ́dẹ̀ẹ́ fi ń wọgbà          Attend to a small problem before it becomes un...
5   Ilé ọba tójó ẹwà ló bùsi                Every cloud has a silver lining
6   Ile oba t'o jo, ewa lo busi             Necessity is mother of invention, creativity i...

转换成.txt文件后,这就是我得到的

concat.to_csv('yoruba_V1.txt', index = None, sep=' ')


Yoruba Meaning
"Adìẹ funfun kò mọ ara rẹ̀lágbà" "Respect yourself"
"Ọbẹ̀ kìí gbé inú àgbà mì" "You should be able to keep secrets"
"À ń pe gbẹ́nàgbẹ́nà ẹyẹ àkókó ń yọjú" "Never think too highly of yourself"
"Díẹ̀ díẹ̀ nimú ẹlẹ́dẹ̀ẹ́ fi ń wọgbà" "Attend to a small problem before it becomes uncontrollable"
"Ilé ọba tójó ẹwà ló bùsi" "Every cloud has a silver lining"
"Ile oba t'o jo, ewa lo busi" "Necessity is mother of invention, creativity is often achieved after overcoming many

Tags: 文件oftointxtyouisad

热门问题