我在var modeldata = {
current: 100,
pipeline: [150, 200, 210, 220]
}
function set(variable, val) {
var path = variable.replace(/\[(\d+)\]/g, '.$1').split('.'),
target = path.pop(),
reference = path.reduce(function (r, k) { return r[k]; }, modeldata);
if (target in reference) {
if (reference[target] === val) {
alert(variable + ' = ' + val + '\nno change necessary');
} else {
reference[target] = val;
}
} else {
alert(variable + ' is not defined');
}
}
set('curren', 100); // modeldata[curren] is not defined, OK
set('current', 100); // no change necessary, OK
set('current', 120); // changing modeldata[current]: 100 to 120, OK
set('pipeline[0]', 42); // changing modeldata[pipeline.0]: 150 to 42, OK
document.write('<pre>' + JSON.stringify(modeldata, 0, 4) + '</pre>');
发行版上使用python3
。在尝试使用Raspbian
模块时,我收到一条错误消息,指出我没有要导入的模块。
错误:
ImportError:没有名为paramiko的模块
我确实拥有它:
paramiko
我尝试通过pi@raspberrypi:~/python $ sudo find / -name paramiko 2>/dev/null
/usr/local/lib/python3.4/dist-packages/paramiko
pi@raspberrypi:~/python $ pip3 install paramiko
Requirement already satisfied (use --upgrade to upgrade): paramiko in /usr/local/lib/python3.4/dist-packages
和import paramiko
调用它。都没有工作。
有关如何使此模块正常工作的任何建议吗?