避免文件末尾的换行符 - Python

bac*_*bac 4 python list

我想避免在python的文本文件末尾写一个换行符.这是一个我有很多问题,我相信很容易修复.这是一个例子:

fileout = open('out.txt', 'w')
list = ['a', 'b', 'c', 'd']
for i in list:
    fileout.write('%s\n' % (i))
Run Code Online (Sandbox Code Playgroud)

这会在文件末尾打印\n字符.如何修改我的循环以避免这种情况?

Win*_*ert 8

fileout = open('out.txt', 'w')
list = ['a', 'b', 'c', 'd']
fileout.write('\n'.join(list))
Run Code Online (Sandbox Code Playgroud)