在csv文件中写入多行

问题描述 投票:0回答:1

我有这个简单的python脚本:

ex = ['line 1\n', 'line 2\n', 'line 3\n']
str_ex = ' '.join(ex)

我想使用f.write将其写入csv文件,但它会将每个字符串写入新行。有没有办法做到这一点?

python-3.x
1个回答
0
投票
ex = ['line 1\\n', 'line 2\\n', 'line 3\\n']
str_ex = ' '.join(ex)
© www.soinside.com 2019 - 2024. All rights reserved.