【发布时间】:2018-10-02 06:50:45
【问题描述】:
我在变量 jss 中有以下字符串。
jss = '''
Java.perform(
function()
{
var item = Java.use("java.util.Random");
console.log("HOOKING random");
item.nextInt.overload("int").implementation = function(a)
{
var ret = this.nextInt(a);
return {0};
}
}
);
'''.format("1234")
我正在尝试使用格式说明符来简单地传递一些值(在本例中为“1234”)。
当我尝试在 iPython 中运行它时,我收到以下错误:
ERROR:root:An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line string', (1, 0))
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-1-a900f760c449> in <module>()
12 }
13 );
---> 14 '''.format("1234")
KeyError: '\n var item = Java'
不确定这里出了什么问题。有人可以帮忙理解吗?
【问题讨论】:
标签: string python-2.7 string-formatting format-specifiers