How do I prevent `format()` from inserting newlines in my string?
<p>It might be my mistake, but <code>cmd = 'program {} {}'.format(arg1, arg2)</code> will always get a newline between the two args... like this
<code>program 1\n2</code></p>

<p>what should i do to put them in one line (<code>cmd</code> need to be passed to system shell)?</p>

<p><code>arg1</code> contains <code>\n</code>. Use <a href="https://docs.python.org/3/library/stdtypes.html#str.strip" rel="nofollow">strip()</a></p>

<pre><code>cmd = 'program {} {}'.format(arg1.strip(), arg2.strip())
</code></pre>

python string-formatting