python + Semicolon written to file is written on the next line
I have this simple python expression:
fscript.write (("update %s va set %s = %s where %s = %s;") % (argv[1],argv[2],vl[0],argv[3],vl[1]))
And I would expect to receive output like this
update some_table va set active_id = 1 where id = 5;
update some_table va set active_id = 1 where id = 3;
...more 开发者_如何学Pythonlines...
However, i'm getting this
update some_table va set active_id = 1 where id = 5
;update some_table va set active_id = 1 where id = 3
...more lines....
Anything i'm missing ?
Thanks in advance
I would try adding a strip()
to your latest parameter that could end with \n
.
fscript.write (("update %s va set %s = %s where %s = %s;") % (argv[1],argv[2],vl[0],argv[3],vl[1].strip()))
Some value of vl[1]
is a string with a newline in it, not an integer.
精彩评论