python - How do I prevent `format()` from inserting newlines in my string? -
it might mistake, cmd = 'program {} {}'.format(arg1, arg2)
newline between 2 args... program 1\n2
what should put them in 1 line (cmd
need passed system shell)?
arg1
contains \n
. use strip()
cmd = 'program {} {}'.format(arg1.strip(), arg2.strip())
Comments
Post a Comment