开发者

Javascript issue inside of a Python Module

I'm trying to have Python run some Javascript, and I am running into a few issues. Namely that when I am trying to inject some text into a textarea of a page, it doesn't seem to work if and only if there is a newline (\n) as part of the variable inserted for the Javascript.

Here's my line:

br.runjs("document.getElementById('edit-body').value = 开发者_如何学编程'%s'" % (brag))

if the variable "brag" has any sort of newline in it at all, the insertion does not work. Any idea how to go around this?


Encode brag as JSON and then use that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜