擅长:python、mysql、java
<p>如果您真的只想将元素连接到逗号+换行符分隔的字符串中,那么使用<a href="https://docs.python.org/3/library/stdtypes.html#str.join" rel="noreferrer">^{<cd1>}</a>方法更容易:</p>
<pre><code>elements = ['hello', 9, 3.14, 9]
s = ',\n'.join(str(el) for el in elements)
# And you can do whatever you want with `s` string:
print(s)
</code></pre>